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

157
Vistas
jest - how to check if a word is a english word

I am using Jest to test for a function, which generate a english word.

I tried below but not working. Just want to check if the word is combined by english characters

  it("generate a english word", () => {
    const word = "APPLE";
    expect(word).toMatch('/^[A-Za-z]*$/');
  });

What's wrong with it?

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

0

This test

expect(word).toMatch('/^[A-Za-z]*$/');

tries to match the string '/^[A-Za-z]*$/'. You want to pass it as a regular expression instead

expect(word).toMatch(/^[A-Za-z]*$/);

The lack of quotation marks in the second case makes all the difference.

Here is the link to the documentation https://jestjs.io/docs/expect#tomatchregexp--string

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