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

feat(config): allow configurable launchers, preprocessors, reporters #533

Conversation

vojtajina
Copy link
Contributor

karma.configure({
  reporters: ['progress', 'html_coverage'],
  browsers: ['Chrome', 'my_chrome']
  preprocessors: {
    '**/*.coffee': ['coffee_bare']
  }
});

karma.defineLauncher('my_chrome', 'Chrome', {
  flags: ['--start-maximized']
});

karma.definePreprocessor('coffee_bare', 'coffee', {
  options: {
    bare: true
  }
});

karma.defineReporter('html_coverage', 'coverage', {
  ...
});

The reason, why I decided for this solution, rather than inlining (as proposed in #317) is that this solution allows using these custom launchers/reporters from CLI. It also makes it easier to create only a single instance of a preprocessor (if the configuration is the same).

In addition to defining/configuring custom reporters/launchers/preprocessors, each can have a global config, eg:

karma.configure({
  coffeePreprocessor: {
    options: {bare: false}
  }
});

What do you think ?

@iammerrick
Copy link
Contributor

I would love to be able to use the latest configuration style to share common configuration. Any idea when a release is coming?

M

@jbastow jbastow mentioned this pull request Jun 5, 2013
@abanctelchevrel
Copy link

Would love it too, especially for the ability to pass flag like --web-security=no to PhantomJS.

karma.defineLauncher('my_chrome', 'Chrome', {
  flags: ['--start-maximized']
});

karma.definePreprocessor('coffee_bare', 'coffee', {
  options: {
    bare: true
  }
});

karma.defineReporter('html_coverage', 'coverage', {
  ...
});

The reason, why I decided for this solution, rather than inlining like this:
browsers = [{
  type: 'Chrome',
  flags: ['--start-maximized']
}];

Is that the solution above allows using these custom launchers from CLI. It also makes it easier to create only a single instance of a preprocessor (if the configuration is the same).

Closes karma-runner#317
@vojtajina vojtajina merged commit 76bdac1 into karma-runner:master Jun 13, 2013
@vojtajina vojtajina deleted the add-dsl-define-launcher-preprocessor-reporter branch June 13, 2013 18:00
@vojtajina
Copy link
Contributor Author

Sorry for delays, it's merged now. I hope to push a new release to npm this week.

@iammerrick
Copy link
Contributor

Awesome anyway to get more tolerant fs integration in that release?

M

@vojtajina
Copy link
Contributor Author

Sure thing, check out the comments I sent, I will wait for that PR. Thanks a bunch @iammerrick !

@hppycoder
Copy link

I was testing out the @canary release of this today and ran into an issue with the defineLauncher working with a custom flag.

karma.defineLauncher('my_chrome','Chrome', { flags: ['–-disable-web-security'] });

Version:
chadsmith@AC02K47M9FFT:~/www/mysite$ karma --version Karma version: 0.9.3

During the launch with LOG_DEBUG turned on:
DEBUG [launcher]: /Applications/Google Chrome.app/Contents/MacOS/Google Chrome --user-data-dir=/var/folders/mc/rsq_5h4962x68r0b25z6lk544001md/T/karma-22288871 --no-default-browser-check --no-first-run --disable-default-apps --start-maximized http://localhost:9877/__karmaRunner/?id=22288871

Did I do something wrong not to have --disable-web-security make it into the path?

@vojtajina
Copy link
Contributor Author

@hppycoder Sorry, my bad. I didn't push chrome-launcher plugin to NPM. I'm getting all the plugins on automated tasks as Karma, so that I won't forget next time, hopefully ;-)

Can you please update karma-chrome-launcher to 0.0.2 ? It should work then...

@hppycoder
Copy link

@vojtajina - Perfect! Fixed the issue now and all seems to be working well. Thanks!

@hppycoder
Copy link

For all you fine Mac friends out there, you will need to set your launcher to look like this.

karma.defineLauncher('my_chrome','Chrome', {
      flags: ['--args –-disable-web-security']
  });

Notice that you have to first send in args, then follow it up with the disable-web-security. If not you will have a tab open in Chrome for nx --disable-web-security which isn't desired.

@vojtajina
Copy link
Contributor Author

@hppycoder and others, I think you gonna hate me... but check out this #604 ;-)

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

Successfully merging this pull request may close these issues.

4 participants