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

Conversation

@thomlom
Copy link
Contributor

thomlom commented Aug 29, 2019

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

This comment has been minimized.

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 left a comment

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
@SimenB
SimenB approved these changes Aug 29, 2019
Copy link
Member

SimenB left a comment

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

return;
}

if (isHook(node)) {

This comment has been minimized.

Copy link
@SimenB

SimenB Aug 29, 2019

Member

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?

This comment has been minimized.

Copy link
@thomlom

thomlom Aug 29, 2019

Author Contributor

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?

This comment has been minimized.

Copy link
@SimenB

SimenB Aug 29, 2019

Member

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
2 checks passed
2 checks passed
Semantic Pull Request ready to be squashed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@SimenB

This comment has been minimized.

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 📦🚀

@SimenB SimenB added the released label Aug 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.