Repository navigation
fix: locate inline snapshots on Windows - #2292
Merged
dprevost-LMI merged 5 commits intoOct 1, 2026
Merged
dprevost-LMI merged 5 commits into
dprevost-LMI merged 5 commits into
Conversation
The inline snapshot matcher removes its own stack frames, so that Vitest's snapshot manager takes the frame of the test as the snapshot location. It found them with `path.sep`, but Node prints the frames of an ES module as `file:///` URLs, with `/` also on Windows. So on Windows the frames stayed, every inline snapshot of a file got the same location (a frame in the `expect` package), and the second different snapshot failed with "toMatchInlineSnapshot with different snapshots cannot be called at the same location". The jasmine-core filter had the opposite problem: it only matched `/`, but Windows paths use `\`. Both filters now accept `/` and `\`. They move to `filterInlineSnapshotStack` in `src/util/stackUtil.ts`, with unit tests for POSIX paths, Windows paths and `file:///` URLs. Found with the multi-remote e2e of webdriverio/webdriverio#15838. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dprevost-LMI
marked this pull request as ready for review
October 1, 2026 02:05
Contributor
|
The new stackUtil tests build their own frames. This test goes through the real matcher and the snapshot client: if a frame of the matcher stays in the stack, both calls get the same location, and the second one fails with "toMatchInlineSnapshot with different snapshots cannot be called at the same location". The other tests have one snapshot per test, or equal snapshots, so they did not catch a wrong location. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The inline snapshot bug of this PR showed only on Windows, where the stack frames are `\` paths or `file:///` URLs, and all CI jobs run on ubuntu. The multi-remote-mocha playground runs the built `lib/` and has 8 different inline snapshots in `snapshot.test.ts`, so on Windows it fails with "toMatchInlineSnapshot with different snapshots cannot be called at the same location" without the fix. The job sets npm's `script-shell` to Git Bash, because the root `compile:check` script, run when the playgrounds install, uses POSIX shell syntax. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The test checks that `setDefaultOptions({ wait: 1 })` makes a failing
assertion fast. It required less than 500ms, but one multi-remote
assertion queries every browser, and on the new Windows job it took
817ms (10 browsers share the runner). Require less than half of the
default wait (5000ms), which still fails if the global option is ignored.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…eline
The 5000ms limit did not catch an ignored `setDefaultOptions({ wait: 1 })`:
the playground's own default wait is 1000ms, so the assertion still passed.
Measure the same failing assertion with an explicit `wait: 1` first, and
require the global-option run to stay within 500ms of it. This keeps the
Windows margin (one assertion queries every browser) and fails again when
the global option is ignored (1057ms against a 614ms limit locally).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3 of 4 tasks
dprevost-LMI
added a commit
that referenced
this pull request
Oct 1, 2026
dprevost-LMI
added a commit
to dprevost-LMI/webdriverio
that referenced
this pull request
Oct 1, 2026
expect-webdriverio 7.0.1 locates inline snapshots on Windows (webdriverio/expect-webdriverio#2292), so the skip is not necessary. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dprevost-LMI
added a commit
to dprevost-LMI/webdriverio
that referenced
this pull request
Oct 1, 2026
7.0.1 locates inline snapshots on Windows, where ES module stack frames are `file:///` URLs (webdriverio/expect-webdriverio#2292). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dprevost-LMI
added a commit
to webdriverio/webdriverio
that referenced
this pull request
Oct 1, 2026
* Upgrade to expect-wdio 7 for multiRemote support * feat(@wdio/globals): expose expect.multiRemote and add multiremote expect e2e - Proxy `expect.multiRemote()` from `@wdio/globals` to expect-webdriverio v7 - Add an e2e spec that covers the multiremote matchers - Document multiremote assertions in the Multiremote guide Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: require webdriverio 9.31.5 where expect-webdriverio 7 is used expect-webdriverio 7 has the peer `webdriverio: ^9.31.5`: its multi-remote matchers need the multi-remote `select` changes of #15538. @wdio/globals, @wdio/runner, @wdio/browser-runner and @wdio/jasmine-framework still accepted `^9.28.0`, so webdriverio 9.28.0 to 9.31.4 satisfied them but not expect-webdriverio. The lockfile also resolved webdriverio 9.31.2 for @wdio/globals. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(e2e): skip the per-instance inline snapshot test on Windows On Windows, expect-webdriverio 7.0.0 does not remove its own stack frames from the inline snapshot error: it filters them with `path.sep`, but ES module frames are `file:///` URLs with `/`. So every inline snapshot of the file resolves to the same frame in the `expect` package, and the second one fails with "toMatchInlineSnapshot with different snapshots cannot be called at the same location" (expected: the first snapshot). Skip the test on win32 until expect-webdriverio has the fix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(e2e): run the per-instance inline snapshot test on Windows again expect-webdriverio 7.0.1 locates inline snapshots on Windows (webdriverio/expect-webdriverio#2292), so the skip is not necessary. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore(deps): update expect-webdriverio to 7.0.1 7.0.1 locates inline snapshots on Windows, where ES module stack frames are `file:///` URLs (webdriverio/expect-webdriverio#2292). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(@wdio/globals): build against the workspace webdriverio `@wdio/globals` had `webdriverio` only as a peer dependency, so pnpm installed it from npm. With the `^9.31.5` peer range, that is `webdriverio@9.32.0`, which declares `getInstance(): WebdriverIO.Browser | undefined`. These global types merged into the build of the services, and `@wdio/testingbot-service` and `@wdio/shared-store-service` failed with "Object is possibly 'undefined'". Add `webdriverio: workspace:*` as a devDependency, as `@wdio/browser-runner` does, so the build uses the workspace package. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
Found with the multi-remote e2e of webdriverio/webdriverio#15838, which fails on Windows only:
The expected value is the snapshot of the other
toMatchInlineSnapshotcall in the same file.Cause:
toMatchInlineSnapshotremoves its own stack frames, so that Vitest's snapshot manager takes the frame of the test as the snapshot location (__INLINE_SNAPSHOT__+ 2). It found them withpath.sep. But Node prints the frames of an ES module asfile:///URLs, with/also on Windows. So on Windows:lib/matchers/snapshot.jsframe stays in the stack.expectpackage.@vitest/snapshotthrows "toMatchInlineSnapshot with different snapshots cannot be called at the same location" for the second different snapshot, with the first snapshot asexpected.The jasmine-core filter had the opposite problem: it only matched
node_modules/jasmine-core/, but Windows paths use\.Fix:
/and\.filterInlineSnapshotStackinsrc/util/stackUtil.ts, so they can be unit-tested. The unit tests loadsrc/, where thelib/frame filter never matches.main(v8) has the same code. I will port the fix after this PR.How you tested
test/util/stackUtil.test.ts: for POSIX paths, Windows paths andfile:///URLs (Windows and POSIX), the location that Vitest takes is the test frame, and jasmine-core frames are removed. With the old filter and the Windowspath.sep, the Windowsfile:///URL case and the Windows jasmine-core case fail.@vitest/snapshot4.1.11_resolveInlineStack, I simulated 2 different inline snapshots at lines 76 and 208::76,:208)file:///frames with the old filter → the same error as the CI log,expected= the line 76 snapshottoHaveHTML.test.tsfailed once at the file level. 2 more full runs passed, and the file passes alone with and without this change.test/snapshot.test.ts: two different inline snapshots in one test, through the real matcher and snapshot client. With one extra matcher frame left in the stack, it fails with the "same location" error. The existing tests did not catch that (one snapshot per test, or equal snapshots).🤖 Generated with Claude Code