I'm having trouble mocking an object differently in two different it blocks. Both blocks end up getting the same mock (in this case where environment: 'development').
Is there a way to do this? I am aware of mockImplementationOnce but that's for functions. Thank you for any advice or guidance!
describe('myTest', () => {
it('should return true if environment is development', () => {
jest.mock('@alias/config', () => {
const config = require.requireActual('@alias/config');
return {
...config,
environment: 'development'
}})
expect(myTest().toEqual(true);
});
it('should return false if environment is not development', () => {
jest.mock('@alias/config', () => {
const config = require.requireActual('@alias/config');
return {
...config,
environment: 'production'
}})
expect(myTest().toEqual(false);
});
});
});