pghalliday / grunt-mocha-test

https://www.npmjs.com/package/grunt-mocha-test
MIT License
362 stars 61 forks source link

Mocha tests with Babel 6 problems #118

Closed ndjordjevic closed 8 years ago

ndjordjevic commented 8 years ago

Hi, I got the following error when I run tests:

Files: server/api/thing/index.spec.js, server/api/user/index.spec.js, server/api/user/user.model.spec.js Options: reporter="spec", require="mocha.conf.js", timeout=5000

Mocha exploded! TypeError: require(...) is not a function at Object. (app.js:30:1) at Module._compile (module.js:413:34) at loader (/Users/ndjordjevic/IdeaProjects/medical-rec5/node_modules/babel-register/lib/node.js:126:5) at Object.require.extensions.(anonymous function) as .js at Module.load (module.js:357:32) at Function.Module._load (module.js:314:12) at Module.require (module.js:367:17) at require (internal/module.js:16:19) at Object. (index.js:12:28) at Module._compile (module.js:413:34) at loader (/Users/ndjordjevic/IdeaProjects/medical-rec5/node_modules/babel-register/lib/node.js:126:5) at Object.require.extensions.(anonymous function) as .js at Module.load (module.js:357:32) at Function.Module._load (module.js:314:12) at Module.require (module.js:367:17) at require (internal/module.js:16:19) at Object. (user.model.spec.js:3:1) at Module._compile (module.js:413:34) at loader (/Users/ndjordjevic/IdeaProjects/medical-rec5/node_modules/babel-register/lib/node.js:126:5) at Object.require.extensions.(anonymous function) as .js at Module.load (module.js:357:32) at Function.Module._load (module.js:314:12)

The extract from Gruntfile.js: mochaTest: { options: { reporter: 'spec', require: 'mocha.conf.js', timeout: 5000 }, unit: { src: ['<%= yeoman.server %>/**/*.spec.js'] }, ...

And mocha.conf.js:

'use` strict';

// Register the Babel require hook
require("babel-register");

var chai = require('chai');

// Load Chai assertions
global.expect = chai.expect;
global.assert = chai.assert;
chai.should();

// Load Sinon
global.sinon = require('sinon');

// Initialize Chai plugins
chai.use(require('sinon-chai'));
chai.use(require('chai-as-promised'));
chai.use(require('chai-things'))`

I'm using the latest versions of node, npm and all deps. When the tests are run manually everything works fine.

pghalliday commented 8 years ago

I can't reproduce this - maybe you could point me at your actual project?

ndjordjevic commented 8 years ago

Here it is: https://github.com/ndjordjevic/medical-rec5

pghalliday commented 8 years ago

ok i think that's too big for me to debug and requires me to install stuff globally (not happening). Can you reproduce the issue in a simpler scenario?

pghalliday commented 8 years ago

closing as old