question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot hit breakpoint inside a test with VS Code IDE

See original GitHub issue

Environment

  1. node -v: [v10.12.0]

  2. npm -v: [6.4.1]

  3. npm ls jest or npm ls react-scripts (if you haven’t ejected): [jest@23.6.0]

  4. your vscode-jest settings if customized:

    • jest.pathToJest? [not set]
    • jest.pathToConfig? [not set]
    • anything else that you think might be relevant? []
  5. Operating system: [Ubuntu 18.04]

Prerequisite

  • are you able to run jest test from command line? [yes]
  • how do yo run your tests from command line? (for example: npm run test or node_modules/.bin/jest) [npm run test]

Steps to Reproduce

Here is a really simple repository that show it is not possible to hit breakpoint into the file user.repository.spec.ts on line 12 const users = await userRepository.getAll(); https://github.com/stherrienaspnet/vscode-jest-debug.git

Relevant Debug Info

[Did not found any resolution yet]

Expected Behavior

[Should break on line 12 when there is a breakpoint and press play vscode-jest-test in launch menu ]

Actual Behavior

[Break on line 12 is not hit]

Thanks you very much!

The fastest (and the most fun) way to resolve the issue is to submit a pull-request yourself. If you are interested, feel free to check out the contribution guide, we look forward to seeing your PR…

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:8
  • Comments:8

github_iconTop GitHub Comments

13reactions
dgreene1commented, Dec 20, 2018

Possible solution: For me, the reason why I couldn’t hit the correct line was due to sourcemaps being incorrect/absent due to an issue with ts-jest when Jest’s collectCoverage option was set to true. https://github.com/kulshekhar/ts-jest/issues/917

Setting that to false allowed the green CodeLens [debug] button to properly hit my code at the desired lines.

9reactions
blikblumcommented, May 5, 2019

When launching jest as a debug task, adding the option disableOptimisticBPs fix this issue

Full context at https://github.com/Microsoft/vscode/issues/60187

Not sure if or how this can be used to fix this issue

Below is a config that works

    {
      "type": "node",
      "request": "launch",
      "name": "Jest All",
      "program": "${workspaceFolder}/node_modules/jest/bin/jest",
      "args": ["unit", "--runInBand"],
      "console": "integratedTerminal",
      "internalConsoleOptions": "neverOpen",
      "disableOptimisticBPs": true
    }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Debugging in Visual Studio Code
One of the great things in Visual Studio Code is debugging support. Set breakpoints, step-in, inspect variables and more.
Read more >
Troubleshoot Breakpoints in the Visual Studio Debugger
If you're debugging optimized code, make sure the function where your breakpoint is set isn't being inlined into another function. The Debugger.
Read more >
Visual Studio Code - Node debugger breakpoints not ...
If I set a breakpoint on a file I open through the VSCode editor the breakpoint is greyed out and when I hover...
Read more >
Debug C# code in Unity
Breakpoints allow you to specify points in your code where you want to pause its execution. In your external code editor, you can...
Read more >
How To Debug Go Code with Visual Studio Code
To debug the test however, maybe because we can't figure out something, all we need to do is add a breakpoint, like we...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found