簡體   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