reactjs - vscode jest 断点未在主编辑器中打开
问题描述
我正在运行一个 react-native 应用程序,当出于某种原因尝试调试 jest 测试时,我似乎无法让它真正停止在代码本身上。相反,vscode 会打开一个单独的编辑器,其中包含转换后的代码。例如:
运行上述内容:
在调试 react-native 应用程序本身时,一切正常。我相信的相关文件是:
babel.config.js
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
};
和开玩笑的配置package.json
"jest": {
"preset": "react-native",
"setupFiles": [
"<rootDir>/jest.setup.js"
],
"globals": {
"__TEST__": true
},
"transform": {
"^.+\\.js$": "<rootDir>/node_modules/react-native/jest/preprocessor.js"
},
"transformIgnorePatterns": [
"node_modules/(?!react-native|native-base-shoutem-theme|@shoutem/animation|@shoutem/ui|tcomb-form-native|react-navigation|@react-native-community/async-storage|@codler/react-native-keyboard-aware-scroll-view)"
],
"testPathIgnorePatterns": [
"App-test.js",
"ui.test.js"
]
}
和vscodelaunch.json
{
"name": "vscode-jest-tests",
"type": "node",
"request": "launch",
"args": ["--runInBand",],
"cwd": "${workspaceFolder}",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"disableOptimisticBPs": true,
"program": "${workspaceFolder}/node_modules/jest/bin/jest",
},
使用我刚刚更新到最新的react-native0.63.4
和节点。v16.4.0
我确信这在过去可以工作,但是在这个项目上没有工作一段时间,所以不确定是什么更新破坏了它(如果它是节点、vscode、react-native 等)。
解决方案
我有同样的问题。通过更改转换配置,我能够使我的设置正常工作:
transform: {
'^.+\\.[jt]sx?$': ['babel-jest', { configFile: require.resolve('./babel.config.js') }]
},
推荐阅读
- perl - 如何使用随机 redis 命令进行 redisbloom
- mysql - 为不存在的数据返回空行
- sql - 如何使用正则表达式替换 SQLite 中的部分字符串?
- vulkan - Vulkan:为什么我们需要在 VkQueuePresentKHR 之后检查窗口调整大小
- javascript - 如果 Xpage 已提交,我可以从 CSJS 中查看吗?
- javascript - 使用 Ajax 在完整日历上显示数据而不显示记录
- c++ - 我如何获取引脚 4 的值以发送到从机并使用 I2C 显示?
- javascript - 是否可以使用 flatbuffers 将序列化数据流式传输到文件中?
- r - 我想模拟具有不同样本大小 n、不同 SD 值和不同 theta 值的一阶 MA(1) 的移动平均过程
- excel - 当两列重复时,如何在 Excel 中使用条件格式突出显示?