【发布时间】:2017-02-09 10:38:52
【问题描述】:
我使用 create-react-app 并且想调试我的单元测试
作为Jest documentation says,可以使用以下命令进行调试:
node --debug-brk --inspect ./node_modules/.bin/jest -i [any other arguments here]
不幸的是,它不适用于 create-react-app。 我得到了这个错误:
node --debug-brk --inspect ./node_modules/.bin/jest -i
Debugger listening on port 9229.
Warning: This is an experimental feature and could change at any time.
To start debugging, open the following URL in Chrome:
chrome-devtools://devtools/remote/serve_file/@60cd6e859b9f557d2312f5bf532f6aec5f284980/inspector.html?experiments=true&v8only=true&ws=localhost:9229/node
Debugger attached.
module.js:457
throw err;
^
Error: Cannot find module '/Users/asafkatz/dev/newmaps/node_modules/.bin/jest'
at Function.Module._resolveFilename (module.js:455:15)
at Function.Module._load (module.js:403:25)
at Timeout.Module.runMain [as _onTimeout] (module.js:590:10)
at tryOnTimeout (timers.js:232:11)
at Timer.listOnTimeout (timers.js:202:5)
Waiting for the debugger to disconnect...
在 create-react-app 上调试 jest 单元测试的正确方法是什么?
【问题讨论】:
-
可能你本地没有安装 jest,试试 'node --debug-brk --inspect $(which jest) -i'
标签: debugging jestjs create-react-app