Skip to content

Saving file resets filename pattern in watch #2728

@marvinhagemeister

Description

@marvinhagemeister

Describe the bug

When running vitest in watch mode, I typically supply a file pattern so that only one test file is re-run. But whenever I save a file, that pattern is dropped and vitest re-runs all tests instead of only the ones that match the supplied pattern.

Reproduction

  1. Create a foo.ts file with export const foo = 2 as content
  2. Create two test files foo.test.ts and fail.test.ts that both import foo.ts
  3. Start vitest in watch mode and use foo as the file pattern
  4. Edit foo.ts and hit save -> Both foo.test.ts and fail.test.ts are run, despite the foo file pattern filter

Stackblitz reproduction: https://stackblitz.com/edit/vitest-dev-vitest-fnc5cv?file=foo.ts,test%2Ffail.test.ts&initialPath=__vitest__

System Info

System:
    OS: macOS 13.1
    CPU: (8) arm64 Apple M1
    Memory: 81.88 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.12.1 - ~/.nvm/versions/node/v18.12.1/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 8.19.2 - ~/.nvm/versions/node/v18.12.1/bin/npm
  Browsers:
    Chrome: 109.0.5414.87
    Firefox: 109.0
    Safari: 16.2

Used Package Manager

npm

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions