【问题标题】:How to set up jest typescripts tests to run in debug mode using vscode如何使用 vscode 设置 jest typescript 测试以在调试模式下运行
【发布时间】:2019-07-12 20:45:52
【问题描述】:

我通过关注https://github.com/Microsoft/TypeScript-React-Starter创建了一个 React 应用

是否有指南或链接提供简单易用的设置来调试用 jest 编写的测试和 vscode 中的酶?我遇到了一些零碎的东西,到目前为止都没有。

如果我点击运行,我会收到错误消息:

【问题讨论】:

    标签: javascript typescript visual-studio-code jestjs


    【解决方案1】:

    对于最新的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 调试器。

    【讨论】:

      猜你喜欢
      • 2021-04-09
      • 2021-12-19
      • 1970-01-01
      • 1970-01-01
      • 2019-12-28
      • 2018-01-13
      • 2023-02-07
      • 1970-01-01
      • 2021-04-09
      相关资源
      最近更新 更多