vitest icon indicating copy to clipboard operation
vitest copied to clipboard

Updating inline snapshot passes without actually updating code in Browser Mode when `slowHijackESM: true`

Open hi-ogawa opened this issue 1 year ago • 0 comments

Describe the bug

See https://github.com/vitest-dev/vitest/pull/5278#issuecomment-1960826263

Currently inline snapshot update is not working due to https://github.com/vitest-dev/vitest/issues/5263, but even after the fix https://github.com/vitest-dev/vitest/pull/5278, it's still not working when slowHijackESM: true for a different reason.

It looks like there's something wrong with stacktrace and it's not finding the right position. I was debug logging around here:

https://github.com/vitest-dev/vitest/blob/4ff7159049e4dd63501cdf512aea3366b55691cf/packages/snapshot/src/port/state.ts#L125-L133

Reproduction

  1. Replace the following code with expect(2).toMatchInlineSnapshot('1'):

https://github.com/vitest-dev/vitest/blob/4ff7159049e4dd63501cdf512aea3366b55691cf/test/browser/test/snapshot.test.ts#L3-L5

  1. Run test
$ pnpm -C test/browser test-fixtures run -u test/snapshot.test.ts -t inline
...

 ✓ test/snapshot.test.ts (3)
   ✓ inline snapshot
   ↓ snapshot [skipped]
   ↓ file snapshot [skipped]

  Snapshots  1 updated 
 Test Files  1 passed (1)
      Tests  1 passed | 2 skipped (3)
   Start at  17:47:52
   Duration  1.22s (transform 0ms, setup 0ms, collect 13ms, tests 7ms, environment 0ms, prepare 0ms)
  1. See test/snapshot.test.ts still has expect(2).toMatchInlineSnapshot('1')

System Info

System:
    OS: Linux 6.7 Arch Linux
    CPU: (12) x64 AMD Ryzen 5 5625U with Radeon Graphics
    Memory: 4.23 GB / 14.98 GB
    Container: Yes
    Shell: 5.2.26 - /bin/bash
  Binaries:
    Node: 18.19.0 - ~/.volta/tools/image/node/18.19.0/bin/node
    Yarn: 1.22.19 - ~/.volta/tools/image/yarn/1.22.19/bin/yarn
    npm: 10.2.3 - ~/.volta/tools/image/node/18.19.0/bin/npm
    pnpm: 8.10.3 - ~/.volta/tools/image/node/18.19.0/bin/pnpm
    bun: 1.0.26 - ~/.volta/bin/bun
  Browsers:
    Chromium: 122.0.6261.57
  npmPackages:
    @vitest/browser: workspace:* => 1.3.1 
    @vitest/coverage-istanbul: workspace:* => 1.3.1 
    @vitest/coverage-v8: workspace:* => 1.3.1 
    @vitest/ui: workspace:* => 1.3.1 
    vite: ^5.0.12 => 5.0.12 
    vitest: workspace:* => 1.3.1

Used Package Manager

pnpm

Validations

hi-ogawa avatar Feb 23 '24 08:02 hi-ogawa