繁体   English   中英

vscode Jest 断点未在主编辑器中打开

[英]vscode jest breakpoint does not open in main editor

我正在运行一个 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"
  ]
}

和 vscode launch.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-native 0.63.4和 node v16.4.0我刚刚更新到最新版本。

我确定这在过去曾经工作过但是没有在这个项目上工作过一段时间所以不确定是什么更新破坏了它(如果它是节点、vscode、react-native 等)。

我有同样的问题。 我能够通过更改转换配置来使我的设置工作:

  transform: {
    '^.+\\.[jt]sx?$': ['babel-jest', { configFile: require.resolve('./babel.config.js') }]
  },

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM