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

Inline snapshot race conditions with vmThreads (sourcemap issue) #5058

Closed
6 tasks done
j4k0xb opened this issue Jan 28, 2024 · 1 comment · Fixed by #5063
Closed
6 tasks done

Inline snapshot race conditions with vmThreads (sourcemap issue) #5058

j4k0xb opened this issue Jan 28, 2024 · 1 comment · Fixed by #5063

Comments

@j4k0xb
Copy link

j4k0xb commented Jan 28, 2024

Describe the bug

When running vitest with --pool=vmThreads it should update the correct inline snapshots, but instead the edits happen at a different inline snapshot or other unrelated line.
It depends on the order of tests and how many there are, works again when deleting e.g. the first 4 tests

Current output:

  expect(`
    b();
    a = c();
  `).toMatchInlineSnapshot(`
  "
      b();
      a = c();
    "
``
      "
          console.log(a = (b(), c()));
        "
    `);

  expect(`
    console.log(a = (b(), c()));
  `).toMatchInlineSnapshot();

Reproduction

https://stackblitz.com/edit/vitest-dev-vitest-rufvf3?file=test%2Fbasic.test.ts

Only affects node, don't run it in StackBlitz

  1. download project
  2. npm install
  3. npm test

System Info

System:
    OS: Linux 5.15 Manjaro Linux
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 5.11 GB / 15.50 GB
    Container: Yes
    Shell: 5.9 - /usr/bin/zsh
  Binaries:
    Node: 20.10.0 - ~/.nvm/versions/node/v20.10.0/bin/node
    Yarn: 1.22.19 - /usr/bin/yarn
    npm: 10.2.3 - ~/.nvm/versions/node/v20.10.0/bin/npm
    pnpm: 8.14.1 - /usr/bin/pnpm
  Browsers:
    Brave Browser: 120.1.61.120
  npmPackages:
    @vitest/ui: latest => 1.2.2 
    vite: latest => 5.0.12 
    vitest: latest => 1.2.2

Used Package Manager

npm

Validations

@hi-ogawa
Copy link
Contributor

hi-ogawa commented Jan 29, 2024

Thanks for reporting an issue.

The way the bug manifested in inline snapshots is very bizarre, but the actual cause seems to be a sourcemap/stacktrace issue on vmThreads. For example, this simple one doesn't work either.

import { expect, test } from 'vitest';

test('hi', () => {
  expect('hi').toMatchInlineSnapshot();
});

It's likely a regression from #4441 and installSourcemapsSupport is forgotten for vm pools. I confirmed the issue doesn't exists before Vitest v1.2.0.

@hi-ogawa hi-ogawa changed the title Inline snapshot race conditions with vmThreads Inline snapshot race conditions with vmThreads (sourcemap issue) Feb 5, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Feb 20, 2024
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 a pull request may close this issue.

2 participants