Skip to content
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

vitest run --update doesn't work for workspaces #5194

Closed
6 tasks done
glacius-mitchell opened this issue Feb 13, 2024 · 0 comments · Fixed by #5199
Closed
6 tasks done

vitest run --update doesn't work for workspaces #5194

glacius-mitchell opened this issue Feb 13, 2024 · 0 comments · Fixed by #5199
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)

Comments

@glacius-mitchell
Copy link

Describe the bug

Running vitest run --update within a monorepo that's configured to use a workspace (https://vitest.dev/guide/workspace.html) doesn't update any snapshots.

I've included a link to a minimal reproduction of this issue on StackBlitz below. It's a pnpm monorepo with a single package containing a single failing snapshot test.

Running pnpm run test:run:update yields the following output:

❯ pnpm run test:run:update

> @ test:run:update /home/projects/vitest-dev-vitest-21kers
> vitest run --update


 RUN  v1.2.2 /home/projects/vitest-dev-vitest-21kers

 ❯ |test-package| snapshot.test.ts (1)
   × snapshot

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

 FAIL  |test-package| snapshot.test.ts > snapshot
Error: Snapshot `snapshot 1` mismatched

- Expected
+ Received

- "original"
+ "updated"

 ❯ eval snapshot.test.ts:4:21
      2| 
      3| test('snapshot', () => {
      4|   expect('updated').toMatchSnapshot();
       |                     ^
      5| });
      6| 

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯

  Snapshots  1 failed
 Test Files  1 failed (1)
      Tests  1 failed (1)
   Start at  10:34:49
   Duration  1.18s (transform 279ms, setup 0ms, collect 282ms, tests 7ms, environment 0ms, prepare 192ms)

 ELIFECYCLE  Command failed with exit code 1.

Observe that the test fails but the snapshot is not updated, despite using the --update flag.

Reproduction

https://stackblitz.com/edit/vitest-dev-vitest-21kers?file=package.json

System Info

$ pnpm dlx envinfo --system --npmPackages '{vitest,@vitest/*,vite,@vitejs/*}' --binaries --browsers
Packages: +1
+
Progress: resolved 1, reused 0, downloaded 1, added 1, done

  System:
    OS: Linux 6.6 Debian GNU/Linux 12 (bookworm) 12 (bookworm)
    CPU: (12) arm64 unknown
    Memory: 5.87 GB / 7.66 GB
    Container: Yes
    Shell: 5.2.15 - /bin/bash
  Binaries:
    Node: 21.6.1 - /usr/local/share/nvm/versions/node/v21.6.1/bin/node
    npm: 10.2.4 - /usr/local/share/nvm/versions/node/v21.6.1/bin/npm
    pnpm: 8.15.1 - /usr/local/share/nvm/versions/node/v21.6.1/bin/pnpm
  npmPackages:
    vitest: 1.2.2 => 1.2.2

Used Package Manager

pnpm

Validations

@sheremet-va sheremet-va added bug p3-minor-bug An edge case that only affects very specific usage (priority) and removed pending triage labels Feb 13, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Mar 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants