使用VSCode或Chrome中的Typescript使用Create React App调试测试 [英] Debugging Tests With Create React App using Typescript in VSCode or Chrome

查看:188
本文介绍了使用VSCode或Chrome中的Typescript使用Create React App调试测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用
https://github.com/Microsoft/ TypeScript-React-Starter

npm install -g create-react-app

npm install -g create-react-app

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

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

我看了很多文章,似乎在转转,但尚未找到如何调试默认app.test.tsx

I've gone through a number of articles, seem to be going around in circles, but have not yet found how i can debug the default app.test.tsx

节点的版本为7.9.0
其他所有内容都应为最新版本

Node is on version 7.9.0 Everything else should be on the latest version.

推荐答案

此问题现已修复。
https://github.com/Microsoft/TypeScript-React- Starter / issues / 46


  1. 安装节点v8.5

  1. Install Node v8.5

更新为Create-React-App
的最新版本(或将react-scripts-ts更新为2.7)

Update to the latest version of Create-React-App (or update the react-scripts-ts to 2.7)

使用$ p $

Configure vscode debugger with

    {
        "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. 如果您使用的是打字稿2.5,请将其添加到项目中
    https://github.com/nicolaserny/create-react -app-typescript / blob / master / packages / react-scripts / template / tsconfig.test.json

  1. If you are on typescript 2.5, add this to your project https://github.com/nicolaserny/create-react-app-typescript/blob/master/packages/react-scripts/template/tsconfig.test.json

这篇关于使用VSCode或Chrome中的Typescript使用Create React App调试测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆