我已经用几乎默认的配置设置了 Reactotron:
import Reactotron from 'reactotron-react-native';
import { reactotronRedux } from 'reactotron-redux';
const reactotron = Reactotron
.configure()
.useReactNative()
.use(reactotronRedux())
.connect();
export default reactotron;
Run Code Online (Sandbox Code Playgroud)
并将其导入到“index.js”中:
if (__DEV__) { import('./app/utils/reactotron'); }
Run Code Online (Sandbox Code Playgroud)
但是在此之后,大多数 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)
Run Code Online (Sandbox Code Playgroud)
看起来我需要将 WebSocket 或其他东西添加到全局变量中以进行测试,但是我应该为所有测试都这样做,还是有什么办法可以为所有测试设置一次?