我试着用Bugsnag在React-Native上运行Jest单元测试,但我得到了错误:
The error below may be caused by using the wrong test environment, see https://jestjs.io/docs/en/configuration#testenvironment-string.
Consider using the "jsdom" test environment.
ReferenceError: window is not defined
1 | import React from 'react';
> 2 | import Bugsnag from '@bugsnag/react-native';
字符串
3条答案
按热度按时间ikfrs5lh1#
为我工作的解决方案:
我们需要在jestSetupFile.js中添加模拟bugsnag拦截器
字符串
hrysbysz2#
我修复了它只是嘲笑Bugsnag:
jest.mock("@bugsnag/react-native", () => jest.fn());
cfh9epnr3#
对我来说,起作用的是:
字符串