jest create-react-app节点环境窗口未定义

时间:2019-01-02 06:52:41

标签: reactjs jestjs create-react-app

我在redux和log4javascript中使用create-react-app。我已经开始编写集成测试并使用npm run test运行--env=node。开始使用node后,我收到window is not defined错误。

在进行玩笑测试时,是否可以将window定义为全局对象?我尝试设置

global.window = jest.fn(() => {
  location: { search: '' }
})

但仍然无法正常工作。

0 个答案:

没有答案