繁体   English   中英

在 VSCode 或 Chrome 中使用 Typescript 使用 Create React App 调试测试

[英]Debugging Tests With Create React App using Typescript in VSCode or Chrome

使用( https://github.com/Microsoft/TypeScript-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 其他所有东西都应该是最新版本。

现在已经修复了。 https://github.com/Microsoft/TypeScript-React-Starter/issues/46

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM