Skip to content
This repository has been archived by the owner on Dec 28, 2023. It is now read-only.

Pass client config to mocha.setup #13

Closed
vojtajina opened this issue Sep 26, 2013 · 10 comments · Fixed by #15
Closed

Pass client config to mocha.setup #13

vojtajina opened this issue Sep 26, 2013 · 10 comments · Fixed by #15
Assignees

Comments

@vojtajina
Copy link
Contributor

// karma.conf.js
module.exports = function(config) {
  config.set({
    client: {
      mocha: {
        ui: 'tdd'
      }
    }
  });
};

Should do:

window.mocha.setup({ui: 'tdd'});
@ghost ghost assigned dignifiedquire Sep 28, 2013
dignifiedquire added a commit to dignifiedquire/karma-mocha that referenced this issue Sep 28, 2013
Now all configuration in `client.config.mocha` is passed to the
setup method of mocha. The default ui style of `'bdd'` is still
set if nothing else is supplied. Also the reporter will be always
overridden as this needs to be our custom one.

Fixes karma-runner#13.
dignifiedquire added a commit to dignifiedquire/karma-mocha that referenced this issue Nov 23, 2013
Now all configuration in `client.config.mocha` is passed to the
setup method of mocha. The default ui style of `'bdd'` is still
set if nothing else is supplied. Also the reporter will be always
overridden as this needs to be our custom one.

Fixes karma-runner#13.
dignifiedquire added a commit that referenced this issue Nov 24, 2013
Now all configuration in `client.config.mocha` is passed to the
setup method of mocha. The default ui style of `'bdd'` is still
set if nothing else is supplied. Also the reporter will be always
overridden as this needs to be our custom one.

Fixes #13.
@Elijen
Copy link

Elijen commented Jun 18, 2014

Seems that this is broken in v0.12.16:

Running "karma:unit" (karma) task
INFO [karma]: Karma v0.12.16 server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
INFO [Chrome 35.0.1916 (Mac OS X 10.9.3)]: Connected on socket oTIjWnX5IIQLP0nDUWEY with id 95771981
Chrome 35.0.1916 (Mac OS X 10.9.3) ERROR
  Uncaught ReferenceError: suite is not defined

My config file:

module.exports = function(config){
    config.set({

        basePath : '../',

        files : [
            'app/Resources/bower_components/angular/angular.js',
            'app/Resources/bower_components/angular-mocks/angular-mocks.js',
            'app/Resources/bower_components/angular-route/angular-route.js',
            'app/Resources/bower_components/angular-bootstrap/ui-bootstrap.min.js',
            'app/Resources/bower_components/angular-sanitize/angular-sanitize.js',
            'src/Me/MyBundle/Resources/public/js/angular/**/*.js',
            'test/unit/**/*.js'
        ],

        autoWatch : true,

        frameworks: ['mocha', 'chai'],

        browsers : ['Chrome'],

        plugins : [
            'karma-chrome-launcher',
            'karma-mocha',
            'karma-chai'
        ],

        junitReporter : {
            outputFile: 'test_out/unit.xml',
            suite: 'unit'
        },

        client: {
            mocha: {
                ui: 'tdd'
            }
        }

    });
};

Let me know if I can include any more debug info.

@maksimr
Copy link
Contributor

maksimr commented Jun 18, 2014

@Elijen Hi!

I tried reproduce it on test project,
but all works correct.

Thanks!

@rickychien
Copy link

It woks for "karma start", but break in "grunt karma".

@Elijen
Copy link

Elijen commented Jun 20, 2014

@rickychien Nice catch! I can confirm that karma start works.

@maksimr
Copy link
Contributor

maksimr commented Jun 20, 2014

@rickychien, @Elijen thanks!

I think need open issue in grunt-karma and I will try to see the error in more detail at the weekend.

Can you create example project in which this error can be reproduced?

@chamrc
Copy link

chamrc commented Jul 31, 2014

Confirmed karma start works, but not grunt karma.

A quick hack to fix it is to include:

    client: {
        mocha: {
            timeout: '5000'
        }
    }

in the Gruntfile of grunt karma

@maksimr
Copy link
Contributor

maksimr commented Aug 1, 2014

Can you write karma settings from Gruntfile here?

Thanks!

@chamrc
Copy link

chamrc commented Aug 2, 2014

So I changed the timeout setting in my karma configuration file already and it does work for karma start but not grunt karma. So I duplicated that setting in the Gruntfile like this:

karma: {
    test: {
        configFile: 'config/test.conf.js',
        client: {
            mocha: {
                timeout: testTimeout // set to 5000
            }
        }
    },
}

and grunt karma started to get the same 5000 ms timeout as well. Seems like grunt-karma is not passing additional arguments (other than the ones specified by karma) in Gruntfile.js to karma.

Well, I think this issue tracking should go to grunt-karma, not grunt-mocha.

@pkozlowski-opensource
Copy link
Member

Guys, since you looked into this one - is it an issue that should be fixed in this repo or is it something that rather belongs to the grunt plugin?

@maksimr
Copy link
Contributor

maksimr commented May 22, 2015

close as obsolete

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

Successfully merging a pull request may close this issue.

7 participants