Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

112
Vistas
Error - This condition will always return 'false' since the types '"$value"' and '""' have no overlap

I have a code as following:

describe("Dynamic testing fields validations", () => {
        it.each`
          field         | value             | expectedMessage
          ${"username"} | ${""}             | ${"username is not allowed to be empty"}
          ${"username"} | ${"b".repeat(4)}  | ${"username length must be at least 5 characters long"}
          ${"username"} | ${"b".repeat(21)} | ${"username length must be less than or equal to 20 characters long"}
          ${"email"}    | ${""}             | ${"email is not allowed to be empty"}
          ${"email"}    | ${"mailcom"}      | ${"email must be a valid email"}
          ${"password"} | ${""}             | ${"password is not allowed to be empty"}
        `(
          `return $expectedMessage when $field is ${"$value"} === "" ? "${"empty"}" : "$value" characters long`,
          async ({ field, expectedMessage, value }) => {
            user.username = value;
            user.password = value;
            user.email = value;

            const res = await exec();

            const {
              validationErrors: { details },
            } = res.body;

            const result = Object.assign({}, ...details);

            expect(result[field]).toBe(expectedMessage);
          }
        );
      });

I'm receiving the following error :

This condition will always return 'false' since the types '"$value"' and '""' have no overlap when I do the conditional check in the ternary operator.

I have tried everything but without success. Can a good soul give me an indication of how to fix this and why I'm receiving this error ?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I think your problem is from this

${"$value"} === "" ? "${"empty"}" : "$value"

From your logic I can understand like this

  • If your value is empty, you return ${"empty"} (which is similar to your "$value")

  • If your value is not empty, you also return "$value"

You can simplify that logic this way

`return $expectedMessage when $field is "$value" characters long`
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda