Webstorm 11 - Run a single Mocha test

I see running a single Mocha test should be possible in Webstorm 11.

But I don't see anything when I righ-click a test name :

test1.png

Am I missing something?

Thanks in advance.

Julien

0
4 comments

It's possible, but you need creating the corresponding run configuration:

mocha.png

See https://www.jetbrains.com/webstorm/help/running-mocha-unit-tests.html

It also works for me when using right-click menu:

mocha1.png

But seems your specs are written in ES6, are they?

0

Elena,

Using a Mocha specific Debug Configuration, I'm indeed able to see the Run/Debug commands in the context menu.

conf1.png
conf2.png


But I'm using TypeScript and when I select the Run command from this context menu, I get an error :

err1.png

Is there a way to make this work using TypeScript?

lena_spb wrote:

But seems your specs are written in ES6, are they?


I'm mainly a Java developer and quite new to Node/Javascript/Webstorm... I mostly use cut and paste examples. So I'm not 100% sure if I'm using ES6 or not! ;-)

Thanks,


Julien

0

Error is expected - as you are running typescript file as javascript, and it can't be run directly, it has to be transpiled to javascript first. Please use Typescript compiler to transpile your tests, and then run the generated javascript tests

0

Indeed, it works when I right-click and choose "run" from the ".js" file instead of the ".ts" file.

Thanks!

0

Please sign in to leave a comment.