Skip to content

fix: exit 1 when vitest list fails collection (fix #11145) - #11146

Merged
sheremet-va merged 1 commit into
vitest-dev:mainfrom
hamed-bavar:fix/list-exit-code
Sep 4, 2026
Merged

sheremet-va merged 1 commit into
vitest-dev:mainfrom
hamed-bavar:fix/list-exit-code

Conversation

@hamed-bavar

Copy link
Copy Markdown
Contributor

Description

Resolves #11145

vitest list prints a collection error and exits 0 when it parses files statically, the default since #11088. --no-static-parse exits 1 for the same file.

Vitest.collect() only sets the exit code in the branch that calls collectTests. This adds the same hasFailed check to the static branch. It has to live in collect(), since start() also calls parseSpecifications to filter specifications for a normal run.

Tests

#11088 moved the only exit code assertion in list.test.ts onto --no-static-parse. I added the same cases for the default path. They fail on main with expected +0 to be 1.

I used Claude Code while investigating this. I reproduced the bug and reviewed the fix myself.

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.
  • Please check Allow edits by maintainers to make review process faster.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • No new functionality, nothing to document.

Changesets

  • The PR title explains the change.

@sheremet-va

Copy link
Copy Markdown
Member

LGTM

@sheremet-va
sheremet-va merged commit 6108b81 into vitest-dev:main Sep 4, 2026
30 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 19, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vitest list exits with code 0 when a test file fails to parse

2 participants