I setup a mocha "run configuration" for tests written in typescript and "run" command executes perfectly.
But when I choose to run a single test by click the "run ..." popup menu in the "run" window, syntax error occurs.
In the run window, WebStorm execute something like:
/usr/local/bin/node /(...)/node_modules/mocha/bin/_mocha --ui bdd --reporter /Applications/(...)/mochaIntellijReporter.js /(...)/my-test.ts --grep "MyTest Basic test$"
It seems that WebStorm passes .ts
file instead of the generated .js
file to mocha, and thus causes syntax errors.
Any ideas or workarounds?
As a workaround, .ts
files can be run instead of the generated .js
: specify --require ts-node/register
in "Extra Mocha options" field (and npm install ts-node
).