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

Filter suites/tests using the mocha grep option #70

Merged
merged 1 commit into from
Jul 6, 2015

Conversation

dej611
Copy link
Contributor

@dej611 dej611 commented Jul 5, 2015

I'm using karma programmatically so I'm generating the karma configuration file dynamically.
I was trying to add the ability to choose the pattern to pass to karma-mocha to filter the suite/tests to execute, so I did read the following in the README:

module.exports = function(config) {
  config.set({
    ...
    client: {
      args: ['--grep', '<pattern>'],
      ...
    }
  });
};

But when I added that to my configuration it didn't work.

I've tried to update both karma and karma-mocha to the latest versions but no luck.

I've just ended up looking at the mocha API to figure out how to pass the grep option and it worked as a charm.
I thought it may be useful to share the thing back.

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project, in which case you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

@dignifiedquire
Copy link
Member

Thanks. Could you please update the commit message to follow our convention?

@googlebot
Copy link

CLAs look good, thanks!

@dej611
Copy link
Contributor Author

dej611 commented Jul 6, 2015

Sure. Is this better?

dignifiedquire added a commit that referenced this pull request Jul 6, 2015
Filter suites/tests using the mocha grep option
@dignifiedquire dignifiedquire merged commit d2f26ae into karma-runner:master Jul 6, 2015
@dignifiedquire
Copy link
Member

Great thanks

@maksimr
Copy link
Contributor

maksimr commented Jul 6, 2015

@dej611 Thanks for PR.

But clinet: {args: ['--grep', '...']} should work if it's doesn't work it's bug.
Could you create gist which reproduce problem

@dej611
Copy link
Contributor Author

dej611 commented Jul 6, 2015

I know, I did debug the code on both karma and karma-mocha side but on my environment it wasn't passed as client arguments. Passing the grep pattern using the mocha API worked.

I'll try to reproduce the issue on a gist.

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.

4 participants