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

Rule proposal: avoid before / after hooks #39

Closed
lo1tuma opened this issue Sep 13, 2015 · 2 comments · Fixed by #84
Closed

Rule proposal: avoid before / after hooks #39

lo1tuma opened this issue Sep 13, 2015 · 2 comments · Fixed by #84
Labels

Comments

@lo1tuma
Copy link
Owner

lo1tuma commented Sep 13, 2015

Using before or after hooks is almost always a sign that you use shared state between multiple tests. This could lead to unwanted side-effects, e.g. some tests only pass/fail if the tests are executed in a specific order.

@jfmengels
Copy link
Collaborator

jfmengels commented Jul 26, 2016

Should this then also forbid beforeEach and afterEach? I'm thinking yes as it follows the same shared state problem.

jfmengels added a commit to jfmengels/eslint-plugin-mocha that referenced this issue Jul 26, 2016
jfmengels added a commit to jfmengels/eslint-plugin-mocha that referenced this issue Jul 26, 2016
@lo1tuma
Copy link
Owner Author

lo1tuma commented Jul 27, 2016

You are right, the same problem could be created by beforeEach and afterEach.
I think if someone needs to distinguish between all and every hooks we can always add an option to the rule later.

lo1tuma added a commit that referenced this issue Jul 27, 2016
Add rule `no-hooks` (fixes #39)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants