Open eliasm307 opened 1 month ago
I'm having to use the jest-runner extension to debug tests, it produces the following CLI command which works:
/usr/bin/env 'NODE_OPTIONS= --require /snap/code/172/usr/share/code/resources/app/extensions/ms-vscode.js-debug/src/bootloader.js --inspect-publish-uid=http' 'VSCODE_INSPECTOR_OPTIONS=:::{"inspectorIpc":"/tmp/node-cdp.446728-f9dba5ff-4.sock","deferredMode":false,"waitForDebugger":"","execPath":"/.../.nvm/versions/node/v20.15.1/bin/node","onlyEntrypoint":false,"autoAttachMode":"always","fileCallback":"/tmp/node-debug-callback-617b8ed7c3b63ffa"}' /home/..../.nvm/versions/node/v20.15.1/bin/node node_modules/.bin/jest /home/..../file.spec.ts -c /home/..../jest.config.ts -t test --runInBand --detectOpenHandles --runInBand
It’s possible that the extension is attempting to auto-generate a debug configuration using your jest.jestCommandLine
but encountered an error; it’s likely due to your jestCommandLine
having mixed Node and Jest commands. A straightforward solution might be to create a custom debug configuration manually:
After the initial debug attempt, the extension typically outputs the generated debug configuration in the terminal window. You can use that output to create a custom configuration. Based on the information you have provided, your debug configuration might look something like this:
{
"type": "node",
"name": "vscode-jest-tests.v2.your-folder",
"request": "launch",
"args": [
"--runInBand",
"--detectOpenHandles",
"--watchAll=false",
"--testNamePattern",
"${jest.testNamePattern}",
"--runTestsByPath",
"${jest.testFile}"
],
"cwd": "absolute-path-to-your-folder",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"disableOptimisticBPs": true,
"program": "absolute-path-to-your-folder/node_modules/.bin/jest",
"runtimeArgs": ["--expose-gc"]
}
In this configuration:
--expose-gc
flag if you need access to garbage collection.Let me know if this helps resolve the issue.
@connectdotz thanks for the response, the config you provided fixes the issue and I'm able to debug via the extension with the node flags applied
Is there any plan to allow the node flags to be configured via extension settings to avoid a custom debug config?
Describe the bug
I am getting a console error when trying to debug tests
To Reproduce Steps to reproduce the behavior:
Expected behavior A clear and concise description of what you expected to happen.
Screenshots If applicable, add screenshots to help explain your problem.
Environment (please complete the following information):
node -v
: 20.16.0npm -v
: 10.8.2"node --expose-gc 'node_modules/.bin/jest' --runInBand --detectOpenHandles"
{ "coverage": true, "showInlineError": true, "type": "on-demand", "runAllTestsOnStartup": false, "deferred": false }
{ "revealOn": "demand", "revealWithFocus": "none", "clearOnRun": "none" },
"jest.useDashedArgs": true,
"jest.useJest30": false,
Prerequisite
Additional context Add any other context about the problem here.
Example terminal output:
The fastest (and the most fun) way to resolve the issue is to submit a pull request yourself. If you are interested, please check out the contribution guide, we look forward to seeing your PR...