Linked Questions

Popular Questions

get the actual function when mocking the entire module

Asked by At

I have mocked a third party library using jest.genMockFromModule('winston'); from this point on wherever I require winston, if I console.log(winston) the mocked functions are also coming. But it should come only in the test case file only.

What am I doing wrong here?

__mocks__
   winston.js
const winston = jest.genMockFromModule('winston');

logger.js

const winston = require('winston')

console.log(winston) // object consist of mockFunctions

Related Questions