Add options or environment variable to 'quick test launch'

So, I have a project with typescript and requirejs. Typescript module output is set to amd syntax.

"module": "amd",

Tests also written in typescript with mocha and chai libraries. But when I'm trying to run selected test through 'Quick test launch', by pressing play button left to the test, I get an error:

ReferenceError: define is not defined

As far as I know, ts-node trying to compile file with options from tsconfig, and mocha doesn't work with amd syntax. If I comment line with "module": "amd" in my tsconfig, everything works great. I've found a solution to override this directive when running test, by creating 'Run/Debug Configuration' with environment variable 

TS_NODE_COMPILER_OPTIONS='{"module":"commonjs"}'

That only works for configuration I've created manually. And I would like to run or debug certain tests by pressing 'Quick test launch' with this evn. variable.

When I press 'Quick test launch'  WebStrom generating run configuration something like this:

"C:\Program Files\nodejs\node.exe" --inspect-brk=53754 <project dir>/node_modules\mocha\bin\_mocha --require ts-node/register --timeout 0 --ui tdd --reporter "C:\Program Files\JetBrains\WebStorm 2017.1.4\plugins\NodeJS\js\mocha-intellij\lib\mochaIntellijReporter.js" <project dir>\tests\FailTest.ts --grep "Fail test test should fail$"

Is it possible to setup generating 'Quick test lauch' command or to use env. parameter or something else to configure it?

1 comment
Comment actions Permalink

Hi there,

Have you tried configuring that under Defaults branch ? Stuff defined there should be used for all newly created Run/Debug Configurations. If clicking "Quick test launch" creates new/temp configuration then those settings from Defaults should be used as well (P.S. this means that you may need to delete existing temp configs if there is one already).

0

Please sign in to leave a comment.