问题
Created an app using (https://github.com/Microsoft/TypeScript-React-Starter)
npm install -g create-react-app
create-react-app my-app --scripts-version=react-scripts-ts
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
Node is on version 7.9.0 Everything else should be on the latest version.
回答1:
This has been fixed now. https://github.com/Microsoft/TypeScript-React-Starter/issues/46
Install Node v8.5
Update to the latest version of Create-React-App (or update the react-scripts-ts to 2.7)
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 -->
- 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
来源:https://stackoverflow.com/questions/45663364/debugging-tests-with-create-react-app-using-typescript-in-vscode-or-chrome