Reputation: 1284
I'm trying to go through a tutorial on react/redux and I am running into an error when it comes to running unit tests with mocha.
when i run 'npm run test' i get the following error (which I suspect has to do with the path or the .jsx extensions).
17 error Windows_NT 6.3.9600
18 error argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\xenoputtss\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "test"
19 error node v5.1.0
20 error npm v3.4.1
21 error code ELIFECYCLE
22 error [email protected] test: `mocha --compilers js:babel-core/register --require ./test/test_helper.js 'test/**/*.@(js|jsx)'`
22 error Exit status 255
23 error Failed at the [email protected] test script 'mocha --compilers js:babel-core/register --require ./test/test_helper.js 'test/**/*.@(js|jsx)''.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the voting-client package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error mocha --compilers js:babel-core/register --require ./test/test_helper.js 'test/**/*.@(js|jsx)'
23 error You can get their info via:
23 error npm owner ls voting-client
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]
my package.json is setup like this for the scripts.
"scripts": {
"test": "mocha --compilers js:babel-core/register --require ./test/test_helper.js 'test/**/*.@(js|jsx)'",
"test:watch": "npm run test -- --watch"
},
Upvotes: 2
Views: 1208
Reputation: 1284
So thanks to skrillcosby for pointing out the specific part that was failing in the command. I was able to correct the issue without installing other software.
The issue was of course that last part of the test command
'test/**/*.@(js|jsx)'
two issues with this are the | symbol and the @ symbol. Replacing this text with the following corrects the issue.
test/**/*.js*
Yes, remove the quotes also.
Also, after discovering the fix I did a search on the tutorial i was working for and discovered that someone else mentioned the fix 2 months ago. http://teropa.info/blog/2015/09/10/full-stack-redux-tutorial.html#comment-2264530944
Upvotes: 0
Reputation: 113
Haha - I'm working on the same tutorial and ran into the same issue.
So Windows doesn't support UNIX-style globbing like that, but I did find a fix / workaround.
1) Use a BASH shell (i.e., Git Bash, CMDer, or cygwin)
2) Replace the single quotes around the glob w/ double quotes
"test": "mocha --compilers js:babel-core/register --require ./test/test_helper.js \"test/**/*.@(js|jsx)\""
That should run the tests on all *.js and *.jsx files. Tested it in Git Bash, CMDer, and cygwin.
Upvotes: 2