Open tusharchutani opened 5 years ago
Npm runner "test:debug": "react-scripts --inspect-brk test --runInBand"
does not work as you expected. As far as I know the CRA codebase, all flags/arguments before the actual command are ignored. Plus, --runInBand
isn't actually passed to the jest runner, but to the react-scripts
binary.
I, personally, would like to have an option to debug tests, despite the fact that I need it in very rare cases.
@miraage This is what the documentation says to do.
@heyimalex That is what is being described as not working in the previous comments I think, i.e.
react-scripts --inspect-brk test --runInBand
then attach chrome via chrome:inspect (or about:inspect). The attach works, but no breakpoints are hit and debugger; statements don't break.
Yeah, I was agreeing with the issue creator; it sounds like they're doing everything right. Also I can replicate this. With a stock cra install the breakpoint works about half of the time. Really strange.
Adding --no-cache
parameter seems to help (at least for me).
"test:debug": "react-scripts --inspect-brk test --no-cache --verbose=false --runInBand",
This parameter is also used in Debugging Tests in Visual Studio Code config, so I guess that can have something with jest cache.
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.
This issue has been automatically closed because it has not had any recent activity. If you have a question or comment, please open a new issue.
This is still an issue.
--no-cache
helps although this fix makes no sense to me.
I am really not sure what I am doing wrong here. I am trying to write unit tests and am using Enzyme and Jest (obviously). Here is what my package.json looks like
Now test are running just fine with npm test and I am trying to debug with npm run test:debug.
Initially the react-script breaks at the first line which is what I would be expect but after that jest just runs without stopping at any debugger break points. I also cannot see any of the .test files in chrome. I am not sure if it is my environment which is to blame or something to do with create-react-app.
Here is a test I am trying to debug