vitest
vitest copied to clipboard
Updating inline snapshot passes without actually updating code in Browser Mode when `slowHijackESM: true`
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
- 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
- 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)
- See
test/snapshot.test.tsstill hasexpect(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
- [X] Follow our Code of Conduct
- [X] Read the Contributing Guidelines.
- [X] Read the docs.
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [X] Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- [X] The provided reproduction is a minimal reproducible example of the bug.