Я использую приложение create-react-app и пытаюсь написать тест jest, который проверяет вывод console.log
Моя функция для тестирования:
export const log = logMsg => console.log(logMsg);
Мой тест:
it('console.log the text "hello"', () => {
console.log = jest.fn('hello');
expect(logMsg).toBe('hello');
});
Вот моя ошибка
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.