From 6e9a124a985489090d74efcfbb357d4a6eef0fe0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 27 Nov 2025 09:08:46 +0000 Subject: [PATCH 1/2] Initial plan From 3ccb454478d8b3f96e4980016cf3f83e61845c40 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 27 Nov 2025 09:15:15 +0000 Subject: [PATCH 2/2] docs: update resolveSnapshotPath example to show context.config usage for projects Co-authored-by: hi-ogawa <4232207+hi-ogawa@users.noreply.github.com> --- docs/config/resolvesnapshotpath.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docs/config/resolvesnapshotpath.md b/docs/config/resolvesnapshotpath.md index 981ff41264c0..c63abfd558d5 100644 --- a/docs/config/resolvesnapshotpath.md +++ b/docs/config/resolvesnapshotpath.md @@ -19,3 +19,23 @@ export default defineConfig({ }, }) ``` + +You can also use the `context` parameter to access the project's serialized config. This is useful when you have multiple [projects](/guide/projects) and want to store snapshots in different locations based on the project name: + +```ts +import { basename, dirname, join } from 'node:path' +import { defineConfig } from 'vitest/config' + +export default defineConfig({ + test: { + resolveSnapshotPath(testPath, snapExtension, context) { + return join( + dirname(testPath), + '__snapshots__', + context.config.name ?? 'default', + basename(testPath) + snapExtension, + ) + }, + }, +}) +```