Skip to content

Ban conditional early returns in test bodies #429

Description

@flyingrobots

Migrated from Method backlog

GitHub Issues are now the live work tracker. Repository docs remain Method evidence.

Field Value
Source backlog docs/method/backlog/cool-ideas/DX_no-conditional-returns-in-tests.md
Archived source docs/archive/backlog/github-issue-migration-2026-06-01/docs/method/backlog/cool-ideas/DX_no-conditional-returns-in-tests.md
Original lane cool-ideas
Original id DX_no-conditional-returns-in-tests
Original legend DX
Original feature testing-quality

Original backlog card

Ban conditional early returns in test bodies

Idea

The test quality audit found multiple tests using
if (!result) { return; } which makes them vacuous — they pass when
the code is broken because they exit before assertions. A simple lint
rule: flag return statements inside it() callbacks that aren't
inside helper functions. The rule: "every it() block must reach at
least one expect() on every code path."

This is the single most impactful test quality rule from the audit.
Could be implemented as a custom ESLint rule or a vitest plugin that
counts expect() calls and warns when a test exits with zero
assertions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:testingPrimary work area: testing.priority:laterDeferred or speculative work.type:featureNew capability or product behavior.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions