Skip to content

fix: add --changed flag support to vitest list command (fix #8270) #8272

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 22, 2025

Conversation

haakonjackfloat
Copy link
Contributor

Description

This PR fixes a bug where the vitest list --changed command was ignoring the --changed flag and showing all tests instead of only those affected by changed files. This was inconsistent with the behavior of the regular vitest --changed command, which correctly filters tests based on git changes.

What this PR solves:

  • The --changed flag now works correctly with the vitest list command
  • Users now see only tests that would be affected by their changes when using vitest list --changed

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.
    • Added comprehensive test suite in test/cli/test/list-changed.test.ts with 5 test cases that verify the fix works correctly
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.
    • No changes to pnpm-lock.yaml - only added test files and modified existing code

Tests

  • Run the tests with pnpm test:ci.
    • All tests pass including the new test cases
    • Manual testing confirmed the fix works as expected

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.
    • No new functionality introduced - this is a bug fix that makes existing functionality work correctly
    • The --changed flag was already documented in the CLI docs, it just wasn't working with the list command

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.
    • Commit message follows convention: fix: add --changed flag support to vitest list command (fix #8270)
    • PR title should be: fix: add --changed flag support to vitest list command

@haakonjackfloat haakonjackfloat marked this pull request as ready for review July 7, 2025 17:39
@@ -888,7 +888,7 @@ export const benchCliOptionsConfig: Pick<

export const collectCliOptionsConfig: Pick<
Copy link
Member

@sheremet-va sheremet-va Jul 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the expected behaviour is that this config extends the original one, not overrides it. It seems like a bug that it doesn't support all other options

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good to know! I'll update accordingly :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sheremet-va I've updated collectCliOptionsConfig to inherit everything from cliOptionsConfig. I also tweaked the description for changed to be more consistent with the json and filesOnly options (e.g. changing Run tests to Print tests)

@sheremet-va sheremet-va merged commit e71a5d0 into vitest-dev:main Jul 22, 2025
14 checks passed
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.

2 participants