Skip to content

feat(test-runner): fail test runs with zero executed tests - #3163

Open
SisyphusZheng wants to merge 1 commit into
modernweb-dev:masterfrom
SisyphusZheng:feat/fail-on-zero-executed-tests
Open

SisyphusZheng wants to merge 1 commit into
modernweb-dev:masterfrom
SisyphusZheng:feat/fail-on-zero-executed-tests

Conversation

@SisyphusZheng

Copy link
Copy Markdown

Problem

A run whose test files all load cleanly but execute zero tests exits 0 today. A glob that matches no files already errors out, so this is the last silent-pass path: a misconfigured files pattern that still matches one stray file, or a test file whose suites end up empty, reports success with nothing tested. Jest and Vitest both fail in this situation by default (Vitest's passWithNoTests defaults to false).

Change

  • A run fails (exit 1) when all sessions loaded but zero tests were executed; skipped tests count as executed.
  • New passWithNoTests option (config + --pass-with-no-tests) restores the old behavior.
  • The default reporter prints an explanation and the escape hatch when a run fails this way.
  • Watch mode and manual mode are unaffected.

Verification

  • Unit tests in test-runner-core: zero-executed → fail; passWithNoTests → pass; skipped-only → pass.
  • Real-browser run via dist/bin.js: zero-executed file → exit 1 with the new message; single test → exit 0; --pass-with-no-tests and config passWithNoTests: true → exit 0; glob matching no files keeps the existing error.
  • test-runner-core and test-runner suites green; unrelated browser-env failures reproduce identically on clean master.

Notes

  • The default flip is a breaking change; the changeset is marked major accordingly.

A test run now fails when all test files loaded but none of them
registered or executed any tests. Previously such a run exited with
code 0, silently passing on misconfigured files patterns or emptied
test files.

Add the passWithNoTests option (config) and --pass-with-no-tests CLI
flag to restore the old behavior. Skipped tests count as executed, so
a run with only skipped tests still passes. Watch mode and manual mode
are unaffected. The default reporter prints an explanation when a run
fails with zero executed tests.
@changeset-bot

changeset-bot Bot commented Sep 29, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f62a204

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 12 packages
Name Type
@web/test-runner-core Major
@web/test-runner Major
@web/test-runner-chrome Patch
@web/test-runner-commands Patch
@web/test-runner-coverage-v8 Patch
@web/test-runner-junit-reporter Patch
@web/test-runner-mocha Patch
@web/test-runner-playwright Patch
@web/test-runner-puppeteer Patch
@web/test-runner-selenium Patch
@web/test-runner-visual-regression Patch
@web/test-runner-webdriver Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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