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(rules): add require-top-level-describe rule #407

Merged
merged 5 commits into from Aug 29, 2019
Merged

feat(rules): add require-top-level-describe rule #407

merged 5 commits into from Aug 29, 2019

Conversation

thomaslombart
Copy link

This PR intends to add a new ESLint rule which enforces the user to add a top-level describe in their test files.

Closes #401

@SimenB
Copy link
Member

SimenB commented Aug 29, 2019

Thanks! Ignore CI, the commitlint thing is somewhat broken. I should look into it at some point...

Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

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

Can you add it to the main readme as well?

src/rules/require-top-level-describe.ts Outdated Show resolved Hide resolved
src/rules/require-top-level-describe.ts Outdated Show resolved Hide resolved
Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

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

Tiny coverage issue from CI, otherwise this LGTM. Super contribution, thank you!

return;
}

if (isHook(node)) {
Copy link
Member

Choose a reason for hiding this comment

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

CI complains that this is not covered. Maybe the else branch? A test with a CallExpression inside a describe that's neither a test nor a hook should probably hit it?

Copy link
Author

Choose a reason for hiding this comment

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

Indeed! I added a dummy test in the valid cases to fix it:

'foo()',

But thinking of it, should we trigger a warning if the user uses a CallExpression that's neither a test or a hook or can we leave it as is?

Copy link
Member

Choose a reason for hiding this comment

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

no, that's fine, I think. Jest itself uses it to e.g. skip tests on windows, or run some other sort of helper 🙂

@SimenB SimenB merged commit 1c40d1a into jest-community:master Aug 29, 2019
@SimenB
Copy link
Member

SimenB commented Aug 29, 2019

🎉 This PR is included in version 22.16.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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 this pull request may close these issues.

[new-rule] Enforce top level describe
2 participants