我已经用几乎默认的配置设置了 Reactotron:
import Reactotron from 'reactotron-react-native';
import { reactotronRedux } from 'reactotron-redux';
const reactotron = Reactotron
.configure()
.useReactNative()
.use(reactotronRedux())
.connect();
export default reactotron;
并将其导入'index.js':
if (__DEV__) { import('./app/utils/reactotron'); }
但在此之后,大多数 Jest 测试都失败并出现下一个错误:
ReferenceError: WebSocket is not defined
8 | .useReactNative()
9 | .use(reactotronRedux())
> 10 | .connect();
| ^
11 |
12 | export default reactotron;
at createSocket (node_modules/reactotron-react-native/dist/index.js:1:13571)
at a.value (node_modules/reactotron-core-client/dist/index.js:1:8397)
at Object.<anonymous> (app/utils/reactotron.js:10:1)
看起来我需要将 WebSocket 或其他东西添加到全局变量中以进行测试,但是我应该为所有测试执行此操作,还是有任何方法可以为所有测试执行一次?