在VSCode或Chrome中使用Typescript创建React App调试测试。

问题描述 投票:1回答:2

创建一个应用程序,使用(https:/github.comMicrosoftTypeScript-React-Starter。)

npm install -g create-react-app。

create-react-app my-app --scripts-version=react-scripts-ts。

我看了很多文章,似乎在兜圈子,但还没有找到如何调试默认的app.test.tsx。

Node是在7.9.0版本上其他的东西都应该是最新的版本。

reactjs typescript2.0 jest create-react-app
2个回答
0
投票

现在这个问题已经解决了。https:/github.comMicrosoftTypeScript-React-Starterissues46。

  1. 安装Node v8.5

  2. 更新到最新版本的Create-React-App(或更新react-scripts-ts到2.7)。

  3. 配置vscode调试器

    {
        "version": "0.2.0",
        "configurations": [
          {
            "name": "Debug CRA Tests",
            "type": "node",
            "request": "launch",
            "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/react-scripts-ts",
            "runtimeArgs": [
              "--inspect-brk",
              "test"
            ],
            "args": [
              "--runInBand",
              "--no-cache",
              "--env=jsdom"
            ],
            "cwd": "${workspaceRoot}",
            "protocol": "inspector",
            "console": "integratedTerminal",
            "internalConsoleOptions": "neverOpen"
          }
        ]
      }
<!-- begin snippet: js hide: false console: true babel: false -->
  1. 如果你是在typecript 2.5上,请将此添加到你的项目中。https:/github.comnicolasernycreat-react-app-typescriptblobmasterpackagesreact-scriptstemplatetsconfig.test.json。
© www.soinside.com 2019 - 2024. All rights reserved.