Skip to content

feat(prefer-ending-with-an-expect): require tests to end in an assertion - #496

Open
unlikelyzero wants to merge 1 commit into
mskelton:mainfrom
unlikelyzero:feat/prefer-ending-with-an-expect
Open

feat(prefer-ending-with-an-expect): require tests to end in an assertion#496
unlikelyzero wants to merge 1 commit into
mskelton:mainfrom
unlikelyzero:feat/prefer-ending-with-an-expect

Conversation

@unlikelyzero

Copy link
Copy Markdown
Collaborator

Adds a prefer-ending-with-an-expect rule, ported from jest/prefer-ending-with-an-expect.

A test that ends with an action rather than an assertion is often unfinished — the setup and interaction got written, but the check that makes the test meaningful never did. It pairs with expect-expect, which only checks that an assertion exists somewhere.

Two Playwright-specific adjustments over the jest version:

  • A trailing test.step(...) is accepted as long as that step itself ends with an assertion (recursively), since wrapping the final check in a step is a normal Playwright pattern.
  • Options are assertFunctionNames and assertFunctionPatterns, matching this plugin's expect-expect rather than jest's star-pattern assertFunctionNames.

expect.soft(...) and expect.poll(...) count as assertions, and a trailing return expect(...) is unwrapped so it counts too.

Not enabled in the recommended config, matching eslint-plugin-jest.

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.

1 participant