Debug w/ Create React App does not seem to work.
See original GitHub issueEnvironment
-
node -v
: 8.9.4 -
npm -v
: 5.6.0 -
npm ls react-scripts
(if you haven’t ejected): react-scripts@1.0.17 -
Operating system: OSX 10.13.2
Steps to Reproduce
- open vscode and ensure I have the latest
vscode-jest
installed npx create-react-app my-app
cd my-app && yarn add @types/jest
- Create the
.vscode/launch.json
file and add the following configuration, from thecreate-react-app
readme.
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug CRA Tests",
"type": "node",
"request": "launch",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/react-scripts",
"args": [
"test",
"--runInBand",
"--no-cache",
"--env=jsdom"
],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
]
}
- Add the following test to
src/App.test.js
it('SIMPLE TEST', () => {
let x = 1;
let y = 2;
expect(1).toEqual(2);
});
- Add a breakpoint, and Click the
Debug
lens above the test.
Expected Behavior
The debug overlay to open and the debugger to break.
Actual Behavior
Error: Cannot find jest.js file
Note: Following some research elsewhere on this issue queue and elsewhere I’ve also tried setting my jest.pathToJest
in my .vscode/settings.json
to a number of different settings with no luck.
Reference:
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (3 by maintainers)
Top Results From Across the Web
React App Not Working? 4 Quick Debugging Tips - Dave Ceddia
If your app is broken, try these things first.
Read more >Debugging create-react-app Build used for Unpacked Chrome ...
My current build process is to build the project with create-react app, then load the unpacked build as an extension.
Read more >Debugging React Apps Created With Create React App in ...
Learn how to get started with debugging a React application that is running on the localhost.
Read more >Strict Mode - React
Strict mode checks are run in development mode only; they do not impact the production build. You can enable strict mode for any...
Read more >Creating a React App - Codecademy
We will use npx, a package runner tool that comes with npm 5.2+ and higher, to install and run create-react-app . This will...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey! So I was experiencing the exact same problem, and it turned out I needed to add a
.babelrc
to the root of my project with just the following:You may need to restart vscode, but I’m not totally sure.
In same way, and for those who don’t like having a lot of configuration file at root of their projects, you can add this to your package.json: