-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add options to resolveSnapshotPath #1620
base: main
Are you sure you want to change the base?
Add options to resolveSnapshotPath #1620
Conversation
✅ Deploy Preview for vitest-dev ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site settings. |
These are the rules for serialisation: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm If it fails to clone, it will throw an error. Context is actually a function, so it cannot be cloned. |
I am not against the idea, but we will need to change how we resolve snapshot paths. If we change vitest/packages/vitest/src/types/config.ts Line 334 in ea9f8b8
- resolveSnapshotPath?: (path: string, extension: string) => string
+ resolveSnapshotPath?: string The module should return |
We have the exact same problem. We'd like to use vitest but are now stuck using jest with https://github.com/igor-dv/jest-specific-snapshot |
I'm using workspace and browser mode and here is my 2 cents:
|
My team wants to save our snapshots in different files, depending on some variables that are defined by a table (
describe.each
). Specifically we want to run the same test for various versions of clients. Storing all of these snapshots in the same file has some very annoying downsides, because the diff tools will confuse the addition and deletion of versions and display generally unhelpful outputs for human review.Today the snapshot path depends only on the test file and the extension (
.snap
) and given that it runs in a different thread (using some RPC protocol) we can't pass down variables using AsyncLocalStorage or other mechanisms with global state.This PR adds the easily customizable Test.Context object to the snapshot resolver, allowing users to conveniently specify a different path per context.
I'm not sure this works due to the nature of the RPC: can it send other parameters than strings? Does it fall apart if the object isn't JSON serialisable? I'm not sure. But I wanted to create this PR already, to make the proposal and gather some opinions.