Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't Mocha resolve this path (or pattern)?

Using windows, I keep running into NPM errors when running scripts. Is pattern matching different between OSX and Win7? Or is this mocha specific?

For example, my tests are in:

src/redux/normalizers/__tests__

and the npm script is:

"test": "mocha --compilers js:babel/register --recursive 'src/**/__tests__/*'"

My console (also in screenshot below) says this:

> mocha --compilers js:babel/register --recursive 'src/**/__tests__/*'

C:\Users\User\WebstormProjects\redux-form\node_modules\mocha\lib\utils.js:626
    throw new Error("cannot resolve path (or pattern) '" + path + "'");
    ^

Error: cannot resolve path (or pattern) ''src/**/__tests__/*''

screenshot: http://i.imgur.com/EL7LOna.png

Edit I was able to change the repo author's test script for the time being to

"test": "mocha --compilers js:babel/register --recursive src/**/__tests__/*"

Perhaps this is just an error on their part which nobody noticed because nobody else uses windows?

Still, I'd like to understand why. Maybe these links are useful for anyone who comes across this:

  • Cannot resolve path in Mocha

  • Two asterisks in file path

like image 738
AlecPerkey Avatar asked Dec 28 '15 00:12

AlecPerkey


1 Answers

You don't need the single quotes. I was able to run the command you provided without them. Like so:

mocha --compilers js:babel/register --recursive src/**/__tests__/*.js
like image 156
thitemple Avatar answered Nov 14 '22 18:11

thitemple