-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
debugger; and breakpoints don't work with node --inspect #1652
Comments
run into the same problem today |
Also in your example if I run
Am I doing something wrong or it doesn't have access to context? |
@maximderbin not sure why you're getting that ReferenceError, edit - just tested, you need to type |
related issue facebook/create-react-app#594 |
This is interesting. Is it possible that node's |
Any news on this? |
Was this ever working before? I don't think This article mentions port forwarding to support debugging VM code. Not sure if that's relevant. Beyond that, maybe it's possible to use websockets within the VM (to support the debugger protocol)? What do you think, @cpojer? |
maybe it is possible to run tests without |
This issue is the biggest reason why I can't switch to Jest. Any updates or ideas on how to make progress? |
I think we need to create a repro without Jest and submit an issue to the node.js bugtracker. |
This NodeJS issue looks related: nodejs/node#7593. Repro case is minimal: var vm = require('vm');
new vm.Script('debugger;').runInContext(vm.createContext());
debugger; Will break three times with |
@cpojer do you think it's a good idea to change the content of http://facebook.github.io/jest/docs/troubleshooting.html#tests-are-failing-and-you-don-t-know-why to reflect that this doesn't work yet? I'm happy to submit a PR for this if that would be helpful -- what should the section say? Delete it? Say "coming soon"? (I love Jest by the way! It makes React testing even more awesome) |
The technique described in the instructions does not pick up breakpoints set with `debugger` statements. This issue is being tracked by jestjs#1652, but it's unclear how long it will take to resolve as it's actually a Node issue. As a work-around, have updated docs to describe connecting an external debugger to the Node process.
I've created a PR for an update to the docs on this: #1998 |
The technique described in the instructions does not pick up breakpoints set with `debugger` statements. This issue is being tracked by #1652, but it's unclear how long it will take to resolve as it's actually a Node issue. As a work-around, have updated docs to describe connecting an external debugger to the Node process.
) The technique described in the instructions does not pick up breakpoints set with `debugger` statements. This issue is being tracked by jestjs#1652, but it's unclear how long it will take to resolve as it's actually a Node issue. As a work-around, have updated docs to describe connecting an external debugger to the Node process.
) The technique described in the instructions does not pick up breakpoints set with `debugger` statements. This issue is being tracked by jestjs#1652, but it's unclear how long it will take to resolve as it's actually a Node issue. As a work-around, have updated docs to describe connecting an external debugger to the Node process.
It seems that node-inspector is not maintained anymore and does not support node 7.*. When I use |
Hi guys, any update on this issue? |
Thanks to all who got this to work 👏 |
So is there anything in particular that needs to be done beyond installing latest node v8.4.0? This vscode launch config works for me :) {
"name": "Debug Jest tests",
"type": "node",
"request": "launch",
"runtimeArgs": [
"--inspect",
"./node_modules/.bin/jest",
"-i"
],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"console": "integratedTerminal"
} |
You just need to run it in "the new way". That is, with The aforementioned |
|
For those using ./node_modules/.bin/react-scripts --inspect-brk test --env=jsdom --runInBand Make sure you're on |
Breakpoints don't hit for me.
See the example project here: This is the launch config:
|
@sparebytes in your console, check your node --version, make sure it's 8.4. The following launch config worked for me with your same specs:
|
) The technique described in the instructions does not pick up breakpoints set with `debugger` statements. This issue is being tracked by jestjs#1652, but it's unclear how long it will take to resolve as it's actually a Node issue. As a work-around, have updated docs to describe connecting an external debugger to the Node process.
Still doesn't work for me on 8.4.0 and I've tried everything. It looks like the break points become red (get activated) after the tests have finished.. Any ideas? |
+1 |
@yevhenchmykhunep did you give this a shot?
By @Timer |
I'm having the issue on node v10.5.0 and [email protected] The break on first line works, but the |
Looks like it not the jest problem, but nodejs problem. I Having the same issue with debugging my application as well. I'm using node v8.11.3 |
I can get the debugger to spawn and hit debugger lines in node 8.
and
However, this debugger line will not cause a stop:
This line will:
So the moral of the story for me appears to be: don't expect debugger breaks to be hit if they are in Jest test code. Why? Maybe someone smarter than me wants to figure that out 😸 |
For those still stuck with this problem, debugging in Chrome DevTools works with the debugger statement. Not an ideal solution, but a decent workaround:
Source: https://jestjs.io/docs/en/troubleshooting#tests-are-failing-and-you-don-t-know-why |
@jchani even with this method, debug statements inside tests will still not break. As @jcollum pointed out. Even with break on first line enabled. Break points inside tests is the type we all want more than any other. Debugging why a test stopped working is a pita without this ability. vuematerial/vue-material#1840 @Samuell1 why do you want to stick with jest 22 when we have 4 tests failing on dev... imo no commit should ever be allowed with failing tests. |
For Vue users: if your debugger statements aren't working... try moving them to your component instead of the jest code, do as little as possible in jest and just check the state of your fixtures... at least until the nodejs team fixes this issue. My import Vue from 'vue'
import { mount } from 'avoriaz'
import f1 from '../fixtures/input-speed.vue'
test('should work with phones autocorrect', async () => {
const wrapper = await mount(f1, {})
const vm = wrapper.vm
await wrapper.vm.$nextTick()
// should work with android autocorrect without waiting
expect(vm.form.server).toBe('autocorrect')
expect(vm.noBind).toBe('Not data binded') // Should work without data binding
}) |
Adding this for anyone having this issue while using the node --inspect-brk node_modules/.bin/jest --runInBand --no-cache --watch |
nvm |
This extension has helped me: https://chrome.google.com/webstore/detail/nodejs-v8-inspector-manag/gnhhdgbaldcilmgcpfddgdbkhjohddkj/related?hl=en It detects node --inspect and opens devTools in Chrome for that websocket. |
It's funny, it seems like i have better luck here if I turn OFF Node Inspector Manager and use |
Sorry, I don't have anything specific here. Sometimes hitting a breakpoint in a file that's behind a sourcemap is just flaky. Next time I need to debug a jest test I'll give NIM another shot. |
I wanted to report back that we encountered the same problem as mentioned by @brien-givens As he said adding @brien-givens thanks for sharing your solution :-) |
For me the issue was with two *.test.js files with the same name (located in different folders). When I removed one of them, debugger was hit in the other without problems. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Currently breakpoints can be set for use with
node debug
using the keyworddebugger;
, but any breakpoints set withdebugger;
when usingnode --inspect
are ignored. This only applies to the test code; breakpoints set withdebugger;
within Jest or other node_module libraries are honored.I set up a test repository to demonstrate the difference: https://github.com/snapwich/jest-inspect. Both methods can be tested by pulling the repo and running the following:
Also, after the initial run-through with
node --inspect
, breakpoints can be applied to the code in the Sources tab. Any breakpoints placed in test code (such as__tests__/jest.js
in jest-inspect repo above) will be ignored, but breakpoints placed in any other files (Jest or other node_modules code) will work correctly when the suite is rerun.node --inspect
is only available in node v6.3.0+ and I'm running on OSX using node v6.4.0 and npm v3.10.3/cc @kentcdodds
The text was updated successfully, but these errors were encountered: