Search code examples
node.jstestingmocha.jsibm-cloud

Configure Mocha to continually run tests fails


I'm trying to configure mocha to run the tests instead of running manually using the command:

node_modules\.bin\mocha -w

I get the error as below.

D:\Downloads\Bluemix\dw0015a\dw0015a\node_modules\mocha\lib\utils.js:626
    throw new Error("cannot resolve path (or pattern) '" + path + "'");
    ^

Error: cannot resolve path (or pattern) '-w'
at Object.lookupFiles (D:\Downloads\Bluemix\dw0015a\dw0015a\node_modules\moc
at D:\Downloads\Bluemix\dw0015a\dw0015a\node_modules\mocha\bin\_mocha:316:30
at Array.forEach (native)
at Object.<anonymous> (D:\Downloads\Bluemix\dw0015a\dw0015a\node_modules\moc
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Function.Module.runMain (module.js:467:10)
at startup (node.js:136:18)
at node.js:963:3

Solution

  • I am able to get a behavior similar to what you report is to have the w option preceded by an "en dash" character (Unicode U+2013) rather than a minus character. Like this:

    $ mocha –w
    /home/x/local/lib/node_modules/mocha/lib/utils.js:626
            throw new Error("cannot resolve path (or pattern) '" + path + "'");
            ^
    
    Error: cannot resolve path (or pattern) '–w'
        at Object.lookupFiles (/home/x/local/lib/node_modules/mocha/lib/utils.js:626:15)
    [... etc ...]
    

    Make sure you are using the minus character (hex value 0x2d).