我正在研究 Jest,我正在尝试将它添加到我的组件中 => github.com/bolket/react-native-scrollview-smart。
当我开始测试时,出现此错误:
$ jest
FAIL lib/ScrollViewSmart.test.js
● Test suite failed to run
Cannot find module 'setupDevtools' from 'setup.js'
at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:179:17)
at Object.<anonymous> (node_modules/react-native/jest/setup.js:30:1)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 0.492s
经过多次尝试,我已将测试移至
__DEV__
文件夹,错误已解决。但是如果我再次运行测试,我又会遇到错误......🤔。
你能向我解释什么是错的吗?
最佳答案
我认为有多种情况会导致同样的错误。就我而言,我有 node_modules
添加到 ignore_dirs
在 .watchmanconfig
文件,我将其删除,错误消失了。尝试运行 jest --no-watchman
看看守望者是否是问题的根源。
关于react-native - 开 Jest - 从 'setupDevtools' 找不到模块 'setup.js',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45104226/