Node Tools for Visual Studio Mocha tests not finding Mocha module
Asked Answered
L

0

6

I have a node project which I've imported into Visual Studio from Web Storm. The mocha tests run fine in Web Storm but in Visual Studio they don't run at all. I've set the test framework on the relevant files and the test discovery phase correctly locates them. When I run the tests they get a green tick even if I modify the system such that they must fail. If I click on the output for a test then I see the error:

NTVS_ERROR: Failed to find Mocha package. Mocha must be installed in the project locally...

I have installed Mocha locally, uninstalled and re-installed but with no difference.

I've managed to get some more specific error information by editing the mocha.js file to print out what's going wrong. The problem occurs during the detectMocha function. The exception that I get in the log now is:

[Error: Cannot find module 'C:\projects\FastLaneVS"\node_modules\mocha'] code: 'MODULE_NOT_FOUND'

Now my assumption is that this extra double quote after my project directory is the problem. I've gone back to the run_tests.js and printed out the argv array to see where the project directory is coming from and indeed it's already appended by the time that function is called.

Now I'm happy to accept that I've done something and added this quote somewhere but I can't find it. I also don't understand why the find_tests should work since that calls the same method and passes the Project Directory in correctly.

In my project it's directory is listed just as . and I've checked both the sln and nsproj files in notepad++ to try and find a spurious double quote.

I'm using VS pro 2013 update 4 with node tools 1.0.21029.05

I could modify the mocha runner to trim a trailing double quote but any ideas on how I can correctly fix this would be great.

Launch answered 19/11, 2014 at 12:13 Comment(1)
No. I used the hack of modifying the runner for a while but wound up sticking with web storm. The project was a PoC so I've assumed if we end up coming back to turn it into production we'll stick with web storm.Launch

© 2022 - 2024 — McMap. All rights reserved.