1

In my Node.js project I have a script in my package.json file that runs the tests using mocha like so:

"scripts": {
 "test": "mocha --reporter list spec/*",
 "test:cov": "istanbul cover _mocha -R spec && open coverage/lcov-report/index.html"
 },

I just tried to run the test script on my Windows machine by running:

npm run test

and I get the following message:

Error: Cannot find module 'C:\Users\[User]\Projects\Leaflet-LightCluster\spec\setup'

I decided to test if it was an issue with mocha by installing mocha globally (i.e. npm install -g mocha) and when I run the same command that is contained in the "test" script everything runs and works fine.

At work I use a Mac and have never had this issue. In fact I can run the same npm command on the same project on my Mac and it works. I'm working on some personal projects on my personal Windows machine and therefore assume this is a Windows issue?

Can anyone verify that this is a Windows issue? Also has anyone encountered this issue and knows how to fix it?

Thanks in advance!

asked Oct 16, 2015 at 3:16

1 Answer 1

1

Here is the configuration I use in both windows and unix environment with mocha installed locally:

"test": "istanbul cover ./node_modules/mocha/bin/_mocha -- -R spec --full-trace --trace ./test/**/*.spec.js"

you can review it here Link through the config there is more complicated as I need to cover forked instances.

answered Oct 16, 2015 at 20:03
Sign up to request clarification or add additional context in comments.

1 Comment

I guess the issue was that it didn't know that their were subfolders within the spec folder. Adding: ./spec/**/*.js worked for both the test and coverage scripts. Thanks for the help!

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.