[Resolved] Webstorm recognizes all but one of my test files as mocha bdd, how do I tell it to run the last one with mocha?

I have a test/ folder (marked as Test Sources Root) full of mocha tests files that test various parts of my codebase. For all but one of my files, I can right-click the file and Run or Debug it and WebStorm correctly runs it with mocha and give me a nice summary of the tests as they're running. I can also right-click on individual tests and intellij can then run or debug just that test. It's quite wonderful.

However it doesn't work for one particular file - when I right-click and run it, WebStorm treats it as a rebular node.js script and then it immediately fails with "ReferenceError: describe is not defined" - why is this? And how do I tell WebStorm to treat it like the rest of my test files?

This is the folder: https://github.com/watson-developer-cloud/node-sdk/tree/c6d334522fc1c86b55eb7bd0e88b85f23d7ce948/test

This is the file that isn't recognized: https://github.com/watson-developer-cloud/node-sdk/blob/c6d334522fc1c86b55eb7bd0e88b85f23d7ce948/test/test.integration-all-services.js

And, here's a variation of it in the branch I'm currently working on where I tried to make it look more like the other files but it didn't seem to change anything:  https://github.com/watson-developer-cloud/node-sdk/blob/ac078b93dd9a6b800122eb7a99ec230e570c9612/test/test.zz.integration-all-services.js

5 comments
Comment actions Permalink

Oh, I sould clarify, if I go to Run-> Edit Configurations, I can manually specify it as mocha and it works for right-clicking on the file. But even then, if I right-click on an individual test, it goes back to the broken behavior of ruing the run the entire thing as a node.js script.

0
Comment actions Permalink

Do you have existing Node.js Run configurations associated with this file (i.e. the ones where this file is chosen as javascript file to run)? If yes, try deleting all them - does the problem persist?

1
Comment actions Permalink

Hah, I thought I had tried that already (there were only the shadow ones that WebStorm automatically creates) - I deleted them before and it didn't seem to work but this time it did. Thanks.

(So, now I'm guessing that it required a combination of that + some of the other changes I made (?)

0
Comment actions Permalink

I have just run into this problem.

I do not have any Node.js Run configurations, and deleting the one created does not work.

I have even created an explicit Mocha configuration for my test file, but the context menu will NOT select it and shows that it wants the "run" type to be Node.js.

HELP!

0
Comment actions Permalink

what IDE version do you use? Please attach a screenshot that shows up the issue

0

Please sign in to leave a comment.