问题描述
使用
()
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.0Everything else should be on the latest version.
推荐答案
此问题现已修复。
-
安装节点v8.5
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 -->
- 如果您使用的是打字稿2.5,请将其添加到项目中
- If you are on typescript 2.5, add this to your projecthttps://github.com/nicolaserny/create-react-app-typescript/blob/master/packages/react-scripts/template/tsconfig.test.json
这篇关于使用VSCode或Chrome中的Typescript使用Create React App调试测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!