I'm using create-react-app and trying to write a jest test that checks the output of a console.log
.
My function to test is:
export const log = logMsg => console.log(logMsg);
My test is :
it('console.log the text "hello"', () => {
console.log = jest.fn('hello');
expect(logMsg).toBe('hello');
});
Here is my error
FAIL src/utils/general.test.js
● console.log the text hello
expect(received).toBe(expected) Expected value to be (using ===): "hello"
Received:
undefined
Difference:
Comparing two different types of values. Expected string but received undefined.