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

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

Closed
6 tasks done
hi-ogawa opened this issue Feb 23, 2024 · 0 comments · Fixed by #5925
Closed
6 tasks done
Assignees
Labels
feat: browser Issues and PRs related to the browser runner p3-minor-bug An edge case that only affects very specific usage (priority)

Comments

@hi-ogawa
Copy link
Contributor

hi-ogawa commented Feb 23, 2024

Describe the bug

See #5278 (comment)

Currently inline snapshot update is not working due to #5263, but even after the fix #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:

private _addSnapshot(
key: string,
receivedSerialized: string,
options: { isInline: boolean; rawSnapshot?: RawSnapshotInfo; error?: Error },
): void {
this._dirty = true
if (options.isInline) {
const stacks = parseErrorStacktrace(options.error || new Error('snapshot'), { ignoreStackEntries: [] })
const stack = this._inferInlineSnapshotStack(stacks)

Reproduction

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

test('inline snapshot', () => {
expect(1).toMatchInlineSnapshot('1')
})

  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 hi-ogawa added pending triage feat: browser Issues and PRs related to the browser runner p2-edge-case Bug, but has workaround or limited in scope (priority) and removed pending triage labels Feb 23, 2024
@hi-ogawa hi-ogawa changed the title Can't update inline snapshot in Browser Mode when slowHijackESM: true Updating inline snapshot passes without actually updating code in Browser Mode when slowHijackESM: true Feb 23, 2024
@sheremet-va sheremet-va added p3-minor-bug An edge case that only affects very specific usage (priority) and removed p2-edge-case Bug, but has workaround or limited in scope (priority) labels May 10, 2024
@sheremet-va sheremet-va self-assigned this Jun 18, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jul 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feat: browser Issues and PRs related to the browser runner p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
Archived in project
2 participants