feat(no-test-return-statement): disallow returning from a test body - #495
Open
unlikelyzero wants to merge 1 commit into
Open
feat(no-test-return-statement): disallow returning from a test body#495unlikelyzero wants to merge 1 commit into
unlikelyzero wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a
no-test-return-statementrule, ported fromjest/no-test-return-statement.Playwright ignores whatever a test body returns.
test('foo', () => somePromise)looks like it makes the test wait, but the test finishes immediately and any failure inside the promise is reported against a later test or lost entirely —awaitis what's wanted. A top-levelreturnwith no argument is dead code.The rule reports a
returnat the top level of a test body only. Returns nested in conditionals, loops, or callbacks declared inside the test are ordinary control flow and aren't reported.One deviation from the jest rule: test bodies passed by reference (
test('foo', myTestFn)) aren't covered, becauseparseFnCallclassifies those calls asconfigrather thantest. That's consistent with how every other rule in this plugin behaves today, so it seemed better than special-casing it here.Not enabled in the recommended config, matching
eslint-plugin-jest.