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

133
Vistas
Jest saying "Not a function" when it is defined as function

I am writing jest for this simple function:

function isVowel(ch) {
  ch = ch.toUpperCase();

  return ch == "A" || ch == "E" || ch == "I" || ch == "O" || ch == "U";
}

this is the jest:

const isVowel = require("./isVowel");
test("a is vowel", () => {
  const ch = isVowel("a");
  expect(ch).toBe("A");
});

on running, it gives error: TypeError: isVowel is not a function

how to resolve it?

almost 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

I assume you write your code in commonjs format due to the way you require it in your test file so you just simply export like this:

// isVowel.js

function isVowel(ch) {
  ch = ch.toUpperCase();

  return ch == "A" || ch == "E" || ch == "I" || ch == "O" || ch == "U";
}

module.exports = isVowel;
almost 4 years ago · Santiago Trujillo 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