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

Cannot hit breakpoint inside a test with VS Code IDE #400

Open
stherrienaspnet opened this issue Oct 29, 2018 · 8 comments
Open

Cannot hit breakpoint inside a test with VS Code IDE #400

stherrienaspnet opened this issue Oct 29, 2018 · 8 comments

Comments

@stherrienaspnet
Copy link

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...

@TheAlmightyBob
Copy link

@stherrienaspnet Have you tried the debugger keyword? Breakpoints are generally unreliable with async functions in my experience, unrelated to jest.

@dgreene1
Copy link

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.
kulshekhar/ts-jest#917

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

@wasker
Copy link

wasker commented Mar 22, 2019

@blikblum
Copy link

blikblum commented May 5, 2019

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

Full context at microsoft/vscode#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
    }

@connectdotz
Copy link
Collaborator

hi, while there might be many reasons the debugger can't find the right breakpoint, you can try 3.0.0-preRelease to see if it resolve your issue...

@rageycomma
Copy link

For me, with the same version you have, it's --collectCoverage in any form - as soon as this is applied, breakpoints on any code except your unit tests are a goner.

@stherrienaspnet
Copy link
Author

stherrienaspnet commented Sep 12, 2019 via email

@nuKs
Copy link

nuKs commented Oct 11, 2019

Same problem, collectCoverage as well.
Weird because jest has deprecated the mapCoverage option because it's now set to true by default so it shouldn't cause any issue.

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

Successfully merging a pull request may close this issue.

8 participants