Skip to content

Commit dc5ace2

Browse files
authored
Playwright config update, move snapshots to their own folder (#1334)
1 parent d11976c commit dc5ace2

18 files changed

+9
-16
lines changed

playwright.config.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { PlaywrightTestConfig, devices } from '@playwright/test';
1+
import { PlaywrightTestConfig, defineConfig } from '@playwright/test';
22

33
// Prevent Vite from attempting to clear the screen
44
process.stdout.isTTY = false;
55

6-
const config: PlaywrightTestConfig = {
6+
const config: PlaywrightTestConfig = defineConfig({
77
testMatch: '**/*.playwright.ts',
88
updateSnapshots: 'none',
99
expect: {
@@ -12,6 +12,10 @@ const config: PlaywrightTestConfig = {
1212
maxDiffPixelRatio: 0.02,
1313
},
1414
},
15+
snapshotDir: 'tests/e2e/snapshots',
16+
// put all snapshots in one directory
17+
// https://playwright.dev/docs/api/class-testconfig#test-config-snapshot-path-template
18+
snapshotPathTemplate: '{snapshotDir}/{arg}-{projectName}-{platform}{ext}',
1519
projects: [
1620
{
1721
name: 'Desktop - Chromium',
@@ -42,6 +46,8 @@ const config: PlaywrightTestConfig = {
4246
// test name. We omit the project name here to keep snapshot names tidy.
4347
name: '',
4448
grep: /@agnostic/,
49+
// put css snapshots in test filename subdirectories
50+
snapshotPathTemplate: '{testFileDir}/{testFileName}-snapshots/{arg}{ext}',
4551
use: {
4652
browserName: 'chromium',
4753
channel: 'chrome',
@@ -52,6 +58,6 @@ const config: PlaywrightTestConfig = {
5258
},
5359
},
5460
],
55-
};
61+
});
5662

5763
export default config;

tests/e2e/fixture.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { test as base } from '@playwright/test';
22

33
type TestFixtures = {
44
port: number;
5-
_autoSnapshotSuffix: void;
65
};
76

87
let testCounter = 0;
@@ -12,18 +11,6 @@ const test = base.extend<TestFixtures>({
1211
const portRange = 100 * workerInfo.workerIndex;
1312
await use(9000 + portRange + testCounter++);
1413
},
15-
16-
// Workaround from https://github.com/microsoft/playwright/issues/11134
17-
// Removes the platform suffix from platform agnostic snapshots.
18-
_autoSnapshotSuffix: [
19-
async ({}, use, testInfo) => {
20-
if (testInfo.title.includes('@agnostic')) {
21-
testInfo.snapshotSuffix = '';
22-
}
23-
await use();
24-
},
25-
{ auto: true },
26-
],
2714
});
2815

2916
export default test;

0 commit comments

Comments
 (0)