我需要模拟一个对象,而不是像通常一样模拟函数。 我已经 -
//config.js .
export default {
foo: 'bar'
}
我已经尝试过 -
import config from './config';
jest.mock('./config');
config.mockReturnValue({
foo: 'zed'
})
also -
import config from './config';
jest.mock('./config');
config.mockImplentation(() => ({
foo: 'zed'
}));
但是它并没有嘲笑任何东西,我像往常一样获取配置文件。
我做错了什么?
jest.mock('./config', () => ({ foo: 'zed' }));
- Jamie Dixon