簡體   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