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