Mocha: display helpful error when if --compilers used incorrectly

Created on 21 Jun 2016  路  5Comments  路  Source: mochajs/mocha

$ mocha --compilers babel/register

/usr/local/lib/node_modules/mocha/bin/_mocha:302
if (mod[0] == '.') mod = join(process.cwd(), mod);
^

TypeError: Cannot read property '0' of undefined
at /usr/local/lib/node_modules/mocha/bin/_mocha:302:10
at Array.forEach (native)
at Object. (/usr/local/lib/node_modules/mocha/bin/_mocha:297:19)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:139:18)
at node.js:968:3

chore help wanted

All 5 comments

The error is legit (correct usage of --compilers is extension:require).

We should probably validate that usage and spit out a more meaningful error message, though.

what can i do with this error?
use mocha --require babel or mocha --compilers babel/register--require ./test/user.js
or any shell others?
i still failed to use --require

I think your original attempt just needs "js:" before the compiler name: --compilers js:babel/register. Let me know if that doesn't work.

I successed with this:
http://jamesknelson.com/testing-in-es6-with-mocha-and-babel-6/
before,i use babel but failed,then use babel-core successed
thanks

--compilers was removed in v6.0.0

Was this page helpful?
0 / 5 - 0 ratings

Related issues

smithamax picture smithamax  路  4Comments

enigmatic00 picture enigmatic00  路  3Comments

Swivelgames picture Swivelgames  路  3Comments

Aarbel picture Aarbel  路  3Comments

CADBOT picture CADBOT  路  3Comments