-
-
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
Debug TypeScript VS Code #7886
Comments
I don't think this is actionable for us. Have you looked at facebook/create-react-app#5319 and tried the workarounds there? I don't use VS Code, so not much help. Maybe @orta has any fresh insight? |
I think this needs an example project, because vscode doesn't support running jest out of the box and there's not enough info here to talk about how you're running jest with |
I'll add the package details and launch.json today. |
I have the same issue. I played around with different jest version. Under jest version 22.1.4 debugging works as expected. Using this version is a current workaround. Working with the latest version of jest, breaks the debugging capabilites in VS Code. I attached a project where the problem occurs. Trying to step into the function "sum" will fail when you try to debug under VS Code. The launch config is configured for a windows system. |
After much experimentation, I was able to get TypeScript spec debugging working with VSCode and Jest v24.x. My setup:
Launch.json: {
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Debug unit tests",
"runtimeArgs": [
"--inspect-brk",
"--nolazy",
"node_modules/jest/bin/jest",
"--runInBand",
"--watch",
"--config=path/to/jest.config.json",
],
"sourceMaps": true,
"disableOptimisticBPs": true,
"cwd": "${workspaceFolder}",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"port": 9229,
"env": {
"NODE_ENV": "test"
}
}
]
} Jest is configured with preset TypeScript is configured with Note that even watch is working! |
Potentially duplicate issue: #6683 |
I figured out what may have been causing issues for me. Don't specify To overcome, i added |
this is a known issue. --collectCoverage=false works |
I found a recipe for debugging jest in VS Code that works great. This comes from https://github.com/microsoft/vscode-recipes/tree/master/debugging-jest-tests Paths below may need to be adjusted based on your particular needs. In this case, this is a monrepo and the actual location of the jest module is a few levels up.
|
Given these new findings, I believe this issue can be closed, thank you for your time and attention to this. |
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. |
🐛 Bug Report
I cannot debug the code under test in jest. I can for the most part debug the actual jest spec file, but when I attempt to drill into the code which is actually being called, it amounts to seeing the VS Code editor pull up the source, with the "current line" always at the bottom of the screen.
I can step through the program logic, seeing the Local Variables changing, return values etc. but the actual stepping through the logic and seeing the lines of code executing is not working. Line breaks do not work.
This is for a TypeScript project, not JavaScript.
To Reproduce
Write a TypeScript module.
Write a TypeScript jest spec file.
Put a breakpoint in the TypeScript module under test (not the jest spec).
Press F5.
No breakpoints ever reach.
Expected behavior
Debugging works.
Run
npx envinfo --preset jest
Paste the results here:
The text was updated successfully, but these errors were encountered: