Running Jest Debug on Windows – SyntaxError: missing ) after argument list

I’m using NestJS and the regular tests works smooth even in my Windows machine. However, when I tried running the debugging mode tests, especially since I’m trying to debug a memory leak, I get this error:

basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
^^^^^^^ SyntaxError: missing ) after argument list

I traced some of the discussions in Github like this:

It looks like the issue is due to this command:

node node_modules/.bin/jest

What it does is it tries to run a script but since I’m in Windows, and the target script is a bash script, it doesn’t work. Running the Windows script jest.cmd doesn’t work either since they are involved from node instead of from the command line interpreter.

I just changed the command to invoke the JS script instead.

node node_modules/jest/bin/jest.js

Works like charm!

Full command:

node --expose-gc --inspect-brk -r tsconfig-paths/register
 -r ts-node/register node_modules/jest/bin/jest.js
 --runInBand --logHeapUsage

That’s it!

This entry was posted in NodeJS and tagged . Bookmark the permalink.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *