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

flag to fail if .only() present. #1125

Closed
smithamax opened this issue Feb 4, 2014 · 4 comments
Closed

flag to fail if .only() present. #1125

smithamax opened this issue Feb 4, 2014 · 4 comments

Comments

@smithamax
Copy link

It would be nice to have a flag to fail the test run if a .only() has been left the suite.

Really need this for CI to people don't forget to remove their .only()s.

Because of the way it's implemented maybe a --no-grep flag would make sense.

@travisjeffery
Copy link
Contributor

in your ci, add a step that greps for onlys before your tests run. this doesn't need to be in mocha.

@martynchamberlin
Copy link

martynchamberlin commented Mar 2, 2017

Yes, but a grep would have to be implemented by everyone. It'd be nice to have this out-of-the-box. It's something I regularly struggle against because sometimes the joy of getting a it.only test to pass is so great that I forget to remove the .only before pushing to a pull request and merging. We need this in our lives.... please. :)

@martynchamberlin
Copy link

FYI for future visitors, here's the grep command that I've used that works for me:

grep -rq --include '*.spec.js' it.only . && echo 'You have it.only() in your tests!' && exit 1

@ScottFreeCode
Copy link
Contributor

Version 3.5.0 recently introduced the --forbid-only flag, actually. Output isn't good yet (it prints nothing to indicate the issue, until we do something like #2874), but it'll fail CI.

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

No branches or pull requests

4 participants