Jest模拟儿童依赖

时间:2018-05-11 11:26:04

标签: mocking jestjs

我有一个配置文件导入到我将要测试的文件中,我需要能够模拟配置文件,但我似乎做错了 - 我有

app.js

import config from './config';
export default class App{
   static get(){
      //refers to config
   }
}

测试文件

import App from './app';  
it('should do something', () => {
   jest.mock(./config, () => {
      return {
         //mocked config
      }
   })
})

但是在运行测试时,我得到的是真正的配置,而不是模拟的配置。有什么想法吗?

0 个答案:

没有答案
相关问题