Skip to content

Commit 3188260

Browse files
macariesheremet-va
andcommitted
feat(browser): provide project reference in ToMatchScreenshotResolvePath (#10138)
Co-authored-by: Vladimir <sleuths.slews0s@icloud.com>
1 parent 2847dfa commit 3188260

3 files changed

Lines changed: 11 additions & 0 deletions

File tree

docs/config/browser/expect.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ receives an object with the following properties:
118118
The value provided to [`attachmentsDir`](/config/attachmentsdir), if none is
119119
provided, its default value.
120120

121+
- `project: TestProject` <Version type="experimental">4.1.6</Version> <Experimental />
122+
123+
The [`TestProject`](/api/advanced/test-project) the test belongs to.
124+
121125
For example, to group screenshots by browser:
122126

123127
```ts

packages/browser/src/node/commands/screenshotMatcher/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ export function resolveOptions(
143143
testFileName: basename(context.testPath),
144144
testName: sanitize(testName, false),
145145
browserName: context.project.config.browser.name,
146+
project: context.project,
146147
} satisfies Parameters<GlobalOptions['resolveDiffPath']>[0]
147148

148149
return {

packages/vitest/src/node/types/browser.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,12 @@ type ToMatchScreenshotResolvePath = (data: {
478478
* if none is provided, its default value.
479479
*/
480480
attachmentsDir: string
481+
/**
482+
* The {@linkcode https://vitest.dev/api/advanced/test-project|TestProject} the test belongs to.
483+
*
484+
* @experimental
485+
*/
486+
project: TestProject
481487
}) => string
482488

483489
export interface ToMatchScreenshotOptions {

0 commit comments

Comments
 (0)