Skip to content

Commit 166544e

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

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
@@ -524,6 +524,12 @@ type ToMatchScreenshotResolvePath = (data: {
524524
* if none is provided, its default value.
525525
*/
526526
attachmentsDir: string
527+
/**
528+
* The {@linkcode https://vitest.dev/api/advanced/test-project|TestProject} the test belongs to.
529+
*
530+
* @experimental
531+
*/
532+
project: TestProject
527533
}) => string
528534

529535
export interface ToMatchScreenshotOptions {

0 commit comments

Comments
 (0)