Skip to content
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

Unable to debug Jest tests using VSCode #73

Closed
marcantoineveilleux opened this issue Jul 28, 2017 · 3 comments
Closed

Unable to debug Jest tests using VSCode #73

marcantoineveilleux opened this issue Jul 28, 2017 · 3 comments

Comments

@marcantoineveilleux
Copy link

marcantoineveilleux commented Jul 28, 2017

With the default project, I am unable to set breakpoint in visual studio code.

Here's my launch.json:

{
  // http://markuseliasson.se/article/debugging-jest-code/
    "version": "0.2.0",
    "configurations": [
        {
          "name":"Jest Tests",
          "type":"node",
          "request":"launch",
          "program":"${workspaceRoot}/node_modules/jest-cli/bin/jest.js",
          "stopOnEntry":false,
          "args":[
              "--runInBand"
          ],
          "cwd":"${workspaceRoot}",
          "preLaunchTask":null,
          "runtimeArgs":[
              "--nolazy"
          ],
          "env":{
              "NODE_ENV":"development"
          },
          "console":"integratedTerminal",
          "sourceMaps":false
        }
    ]
}
@alexjoverm
Copy link
Owner

Hi @marcantoineveilleux. I'm sorry but I don't think this issue belongs to this repository.

If you can set breakpoints with ts-jest, you should be able to do it here. So I suggest better ask in stackoverflow about it ot open an issue in ts-jest.

Nonetheless, I'll keep this issue open some days in case someone knows the answer

@mattmazzola
Copy link
Contributor

I had opened similar issues on VSCode and Jest repos.
Two things, it only works with legacy protocol (not inspect), and it does not work with Node 7 or 8 due to breaking changes in the vmContext stuff.

Root Issue:
nodejs/node#7593

See related issues:
microsoft/vscode#28007
jestjs/jest#3748

@tonysneed
Copy link

@mattmazzola This launch.json file works for me. I'm able to set breakpoints and hit them.

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Tests",
      "type": "node",
      "request": "launch",
      "program": "${workspaceRoot}/node_modules/jest/bin/jest.js",
      "sourceMaps": true,
      "runtimeArgs": [
        "-i"
      ],
      "env": {
        "NODE_ENV": "development"
      },
      "outFiles": [
        "${workspaceRoot}/dist/**/*"
      ],
      "cwd": "${workspaceRoot}"
    }
  ]
}

The weird thing is that I have to press F5 twice, because the first time the debugger exits without hitting the breakpoint. But it hits the breakpoint the second time through. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants