簡體   English   中英

如何使用 vscode 設置 jest 打字稿測試以在調試模式下運行

[英]How to set up jest typescripts tests to run in debug mode using vscode

我按照https://github.com/Microsoft/TypeScript-React-Starter創建了一個 React 應用程序

是否有指南或鏈接提供簡單易用的設置來調試在 vscode 中用 jest 和酶編寫的測試? 我遇到了一些零碎的事情,到目前為止沒有任何工作。

如果我點擊運行,我收到錯誤: 在此處輸入圖片說明

對於最新的create-react-app (2.1.5) 和react-scripts-ts (3.1.0),在你的項目根目錄創建一個.vscode目錄並添加以下launch.json

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Debug CRA Tests",
      "type": "node",
      "request": "launch",
      "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/react-scripts-ts",
      "args": [
        "test",
        "--runInBand",
        "--no-cache",
        "--no-watch",
        "--env=jsdom"
      ],
      "cwd": "${workspaceRoot}",
      "protocol": "inspector",
      "console": "integratedTerminal",
      "internalConsoleOptions": "neverOpen"
    }
  ]
}

然后使用Debug CRA Tests配置啟動 VSCode 調試器。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM