Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mocha v3 triggers "mismatched anonymous define" error #50

Open
viveleroi opened this issue Aug 3, 2016 · 3 comments
Open

Mocha v3 triggers "mismatched anonymous define" error #50

viveleroi opened this issue Aug 3, 2016 · 3 comments

Comments

@viveleroi
Copy link

After upgrading to Mocha 3.0.0, karma-requirejs throws an error when trying to run tests:

Mismatched anonymous define() module: function () { return JSON3; }

This does not occur when I downgrade to Mocha 2.5.3.

I'm using:

  • karma 1.1.2
  • karma-requirejs 1.0.0
  • mocha 3.0.0
  • phantomjs-prebuilt 2.1.10

We use gulp to activate the tests:

gulp.task('test:components', function() {
    var karma = require('karma').server;

    karma.start({
        configFile: basePath + '/karma.conf.js'
    });
});

And I've reduced our karma.conf.js file to a very limited set:

module.exports = function(config) {
    config.set({
        frameworks: ['mocha', 'requirejs'],
        browsers: ['PhantomJS'],
        port: 9876,
        singleRun: true
    });
};

Here's the full startup log:

03 08 2016 12:54:05.189:INFO [karma]: Karma v1.1.2 server started at http://localhost:9876/
03 08 2016 12:54:05.192:INFO [launcher]: Launching browser PhantomJS with unlimited concurrency
03 08 2016 12:54:05.198:INFO [launcher]: Starting browser PhantomJS
03 08 2016 12:54:05.786:INFO [PhantomJS 2.1.1 (Mac OS X 0.0.0)]: Connected on socket /#0At0vvA1atYS3xCnAAAA with id 32375243
PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR
  Error: Mismatched anonymous define() module: function () {
        return JSON3;
      }
  http://requirejs.org/docs/errors.html#mismatch
  at /Users/viveleroi/project/node_modules/requirejs/require.js:143
@fearphage
Copy link

I filed this bug officially with the Mocha team - mochajs/mocha#2424.

@lddubeau
Copy link

lddubeau commented Aug 7, 2016

I can reproduce the problem but the issue is not with karma-requirejs. It is with Mocha itself. Switch your frameworks so that they are like this:

frameworks: ['requirejs', 'mocha']

and the problem should be resolved. I'm going to explain why on the Mocha issue that fearphage filed.

@boneskull
Copy link

This should be fixed in mocha@3.0.2 (publishing in a few minutes).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants