Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Calculator

0

98
Views
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
7 months ago ยท Juan Pablo Isaza
Answer question
Find remote jobs