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

Can't debug tests with version 5.1 of plugin #997

Closed
StMartin81 opened this issue Jan 25, 2023 · 4 comments · Fixed by #998
Closed

Can't debug tests with version 5.1 of plugin #997

StMartin81 opened this issue Jan 25, 2023 · 4 comments · Fixed by #998
Labels

Comments

@StMartin81
Copy link

Environment

  1. vscode-jest version: v5.1.0
  2. node -v: v18.13.0
  3. npm -v: 9.3.1
  4. npm ls jest:
├─┬ @vue/[email protected]
│ └── [email protected] deduped
├── [email protected]
└─┬ [email protected]
  └── [email protected] deduped
  1. your vscode-jest settings if customized: -
  2. Operating system: Windows 11

Behavior

With version 5.1 of this plugin I'm not able to debug the tests anymore. With version v4.6.0 it was possible to debug the tests.

I saw that the command line for running the tests did change:
v4.6.0:

PS C:\repositories\myProject>  C:; cd 'C:\repositories\myProject'; ${env:NODE_OPTIONS}='--require "c:/Users/mstolpe/AppData/Local/Programs/Microsoft VS Code/resources/app/extensions/ms-vscode.js-debug/src/bootloader.bundle.js" --inspect-publish-uid=http'; ${env:VSCODE_INSPECTOR_OPTIONS}='{"inspectorIpc":"\\\\.\\pipe\\node-cdp.31144-4.sock","deferredMode":false,"waitForDebugger":"","execPath":"C:\\Program Files\\nodejs\\node.exe","onlyEntrypoint":false,"autoAttachMode":"always","fileCallback":"C:\\Users\\mstolpe\\AppData\\Local\\Temp\\node-debug-callback-408ed9fbf17fa557"}'; & 'C:\Program Files\nodejs\node.exe' '.\node_modules\jest\bin\jest' '--runInBand' '--watchAll=false' '--testNamePattern' '.*' '--runTestsByPath' 'C:\repositories\myProject\tests\unit\myTest.spec.ts'

v5.1.0:

PS C:\repositories\myProject>  ${env:NODE_OPTIONS}='--require "c:/Users/mstolpe/AppData/Local/Programs/Microsoft VS Code/resources/app/extensions/ms-vscode.js-debug/src/bootloader.bundle.js" --inspect-publish-uid=http'; ${env:VSCODE_INSPECTOR_OPTIONS}='{"inspectorIpc":"\\\\.\\pipe\\node-cdp.35324-1.sock","deferredMode":false,"waitForDebugger":"","execPath":"C:\\Program Files\\nodejs\\node.exe","onlyEntrypoint":false,"autoAttachMode":"always","fileCallback":"C:\\Users\\mstolpe\\AppData\\Local\\Temp\\node-debug-callback-bc64ae59dd403a5d"}'; & 'C:\Program Files\nodejs\node.exe' '.\node_modules\.bin\jest.cmd' '--runInBand' '--watchAll=false' '--testNamePattern' '.*' '--runTestsByPath' 'C:\repositories\myProject\tests\unit\myTest.spec.ts'

This is the output:

Debugger attached.
Waiting for the debugger to disconnect...
C:\repositories\myProject\node_modules\.bin\jest.cmd:1
@ECHO off
^

SyntaxError: Invalid or unexpected token
    at internalCompileFunction (node:internal/vm:74:18)
    at wrapSafe (node:internal/modules/cjs/loader:1141:20)
    at Module._compile (node:internal/modules/cjs/loader:1182:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1272:10)
    at Module.load (node:internal/modules/cjs/loader:1081:32)
    at Module._load (node:internal/modules/cjs/loader:922:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47

Node.js v18.13.0
@StMartin81 StMartin81 changed the title Can't debug tests with versions 5.1 of plugin Can't debug tests with version 5.1 of plugin Jan 25, 2023
@galaxyfeeder
Copy link

+1 over here with v5.1:

node -v: 16.10
npm -v 7.24.0
OS: Macos Ventura 13.0

@connectdotz
Copy link
Collaborator

connectdotz commented Jan 26, 2023

Shoot, yes, looks like there is a problem... This looks like an auto-config issue. It used .\node_modules\.bin\jest.cmd instead of .\node_modules\jest\bin\jest.

You can workaround this by clone the auto-config vscode-jest-tests.v2 to launch.json (see https://github.com/jest-community/vscode-jest#how-to-debug-tests), then changing the program path jest.cmd to jest. Or downgrade to 4.6 until the patch is ready.

[update]
Actually, the easiest workaround might be to just add an "test": "jest" script in package.json then reload the window.

I will take a closer look tomorrow to see how we can patch it soon.

@connectdotz
Copy link
Collaborator

We just released v5.2.1 pre-release with the fix. Please give it a try and let us know how it works for you.

@StMartin81
Copy link
Author

It works. Thank you!

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

Successfully merging a pull request may close this issue.

3 participants