• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

179
Vistas
Test case failed in Jest with " expect(received).toBe(expected) // Object.is equality"

I tried to work on basic Jest testing in JavaScript. I went through the docs file and worked accordingly. Everything look good to me but a simple test case is not passing. I have attached the screenshot for the issue along with the code and package.json.Screenshot Screenshot2

const functions = {
  add: (num1, num2) => {
    num1 + num2;
  },
};

module.exports = functions;


`//Testing `
const functions = require("./functions");

    test("Add 2 + 2 equal 4", () => {
      expect(functions.add(2, 2)).toBe(4);
    });

Error
expect(received).toBeCloseTo(expected)

Matcher error: received value must be a number

Received has value: undefined
almost 3 years ago · Juan Pablo Isaza
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 Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda