microsoft / vscode-recipes

MIT License
5.86k stars 577 forks source link

Debug Jest Tests recipe fails on Mac #321

Open David-Rickard opened 2 years ago

David-Rickard commented 2 years ago

https://github.com/Microsoft/vscode-recipes/tree/main/debugging-jest-tests @jagreehal

When running on MacOS, it fails with this error:

Uncaught SyntaxError /Users/david/Projects/app-dasher-onboarding/node_modules/.bin/jest:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
          ^^^^^^^

SyntaxError: missing ) after argument list
    at compileFunction (node:vm:352:18)
    at wrapSafe (node:internal/modules/cjs/loader:1032:15)
    at Module._compile (node:internal/modules/cjs/loader:1067:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Module._load (node:internal/modules/cjs/loader:822:12)
    at executeUserEntryPoint (node:internal/modules/run_main:77:12)
    at <anonymous> (node:internal/main/run_main_module:17:47)

It's fixed if I use this setting from the Windows config:

"program": "${workspaceFolder}/node_modules/jest/bin/jest"

I'm wondering if it's because I'm running on an M1 chip.

This is also failing in the same way when I try to debug an individual test using the Jest VSCode extension.

David-Rickard commented 2 years ago

Actually I think it might be using the pnpm package manager that is requiring the alternate config. This launch config works as well: https://gist.github.com/esamattis/600d6964f3e6ab6e8e7da9a05bfe6574