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 no-test-return-statement #136

Merged
merged 1 commit into from Aug 9, 2018
Merged

feat(rules): add no-test-return-statement #136

merged 1 commit into from Aug 9, 2018

Conversation

mattphillips
Copy link
Member

Adds a rule for not returning inside of a test. Related issue in Jest: jestjs/jest#6516

@SimenB
Copy link
Member

SimenB commented Aug 9, 2018

What about test('hello', () => somePromise);?

@SimenB
Copy link
Member

SimenB commented Aug 9, 2018

If that should be allowed, let's call it no-test-return-statement or something

@mattphillips
Copy link
Member Author

Yeah that should be allowed, I'll update the name :)

@mattphillips mattphillips force-pushed the no-test-return branch 2 times, most recently from cd99d8e to 1a53389 Compare August 9, 2018 13:27
README.md Outdated
@@ -90,6 +90,7 @@ for more information about extending configuration files.
| [no-jest-import][] | Disallow importing `jest` | ![recommended][] | |
| [no-large-snapshots][] | Disallow large snapshots | | |
| [no-test-prefixes][] | Disallow using `f` & `x` prefixes to define focused/skipped tests | | ![fixable-green][] |
| [no-test-return-statement][] | Disallow returning from tests | | |
Copy link
Member

Choose a reason for hiding this comment

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

"Disallow explicitly returning from tests"?

@@ -0,0 +1,47 @@
# Disallow returning from tests (no-test-return-statement)

Tests in Jest are void and cannot return values.
Copy link
Member

Choose a reason for hiding this comment

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

"should be"? Seeing as you can return a promise, and that's unlikely to change (I don't think it's possible to differentiate between an async function and a promise-returning one (at least not if it's transpiled))

@SimenB
Copy link
Member

SimenB commented Aug 9, 2018

/cc @aaronabramov FYI

@SimenB SimenB changed the title feat(rules): add no-test-return feat(rules): add no-test-return-statement Aug 9, 2018
Copy link
Contributor

@rickhanlonii rickhanlonii left a comment

Choose a reason for hiding this comment

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

SGTM

@SimenB SimenB merged commit 9fca36b into master Aug 9, 2018
@SimenB SimenB deleted the no-test-return branch August 9, 2018 16:55
@SimenB
Copy link
Member

SimenB commented Aug 9, 2018

🎉 This PR is included in version 21.20.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
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants