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

feature: Pass client configuration to `mocha.setup method. #15

Merged
merged 1 commit into from
Nov 24, 2013

Conversation

dignifiedquire
Copy link
Member

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.


I know that tests are missing but I'm not sure how it's possible to test this with the current testing setup.

@andrew-luhring
Copy link

If this works now... doesn't this mean that the readme needs to be updated?

var passedIn = karma.config.mocha;

// Overwrite reporter because otherwise everything breaks down.
passedIn.reporter = defaultConfig.reporter;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will leak memory, you should not modify the karma.config as that is in the parent (long life) frame.
Let's create a clone.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACtually, this might be better:

var mochaConfig = {
  reporter: createMochaReporterConstructor(window.__karma__),
  ui: 'bdd',
  globals: ['__cov*']
};

if (window.__karma__.config && window.__karma__.config.mocha) {
  // copy all the properties (except reporter) from window.__karma__.mocha to mochaConfig
  // + the globals merging
}

This should work, as there's gonna be only references from the child frame to parent, not the other way around.

@vojtajina
Copy link
Contributor

@dignifiedquire this is awesome!

Check out my code, can you refactor it please?
Also, can you add an example into the README? (showing how to use client: {mocha: {ui: 'tdd'}} or something)

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
Copy link
Member Author

@vojtajina ping

vojtajina added a commit that referenced this pull request Nov 24, 2013
feature: Pass client configuration to `mocha.setup method.
@vojtajina vojtajina merged commit 6f5730e into karma-runner:master Nov 24, 2013
@vojtajina
Copy link
Contributor

Thanks @dignifiedquire you are fast! Btw, it's feat not feature ;-)

@dignifiedquire
Copy link
Member Author

I guess I just type so fast that I try to be more descriptive than I need to be ;)

@vojtajina
Copy link
Contributor

Rebased to 4df9ba6, otherwise it wouldn't get released neither it would get into changelog.

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

Successfully merging this pull request may close these issues.

Pass client config to mocha.setup
3 participants