Skip to content

Commit

Permalink
Playwright config update, move snapshots to their own folder (#1334)
Browse files Browse the repository at this point in the history
  • Loading branch information
renrizzolo authored Mar 2, 2024
1 parent d11976c commit dc5ace2
Show file tree
Hide file tree
Showing 18 changed files with 9 additions and 16 deletions.
12 changes: 9 additions & 3 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { PlaywrightTestConfig, devices } from '@playwright/test';
import { PlaywrightTestConfig, defineConfig } from '@playwright/test';

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

const config: PlaywrightTestConfig = {
const config: PlaywrightTestConfig = defineConfig({
testMatch: '**/*.playwright.ts',
updateSnapshots: 'none',
expect: {
Expand All @@ -12,6 +12,10 @@ const config: PlaywrightTestConfig = {
maxDiffPixelRatio: 0.02,
},
},
snapshotDir: 'tests/e2e/snapshots',
// put all snapshots in one directory
// https://playwright.dev/docs/api/class-testconfig#test-config-snapshot-path-template
snapshotPathTemplate: '{snapshotDir}/{arg}-{projectName}-{platform}{ext}',
projects: [
{
name: 'Desktop - Chromium',
Expand Down Expand Up @@ -42,6 +46,8 @@ const config: PlaywrightTestConfig = {
// test name. We omit the project name here to keep snapshot names tidy.
name: '',
grep: /@agnostic/,
// put css snapshots in test filename subdirectories
snapshotPathTemplate: '{testFileDir}/{testFileName}-snapshots/{arg}{ext}',
use: {
browserName: 'chromium',
channel: 'chrome',
Expand All @@ -52,6 +58,6 @@ const config: PlaywrightTestConfig = {
},
},
],
};
});

export default config;
13 changes: 0 additions & 13 deletions tests/e2e/fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { test as base } from '@playwright/test';

type TestFixtures = {
port: number;
_autoSnapshotSuffix: void;
};

let testCounter = 0;
Expand All @@ -12,18 +11,6 @@ const test = base.extend<TestFixtures>({
const portRange = 100 * workerInfo.workerIndex;
await use(9000 + portRange + testCounter++);
},

// Workaround from https://github.com/microsoft/playwright/issues/11134
// Removes the platform suffix from platform agnostic snapshots.
_autoSnapshotSuffix: [
async ({}, use, testInfo) => {
if (testInfo.title.includes('@agnostic')) {
testInfo.snapshotSuffix = '';
}
await use();
},
{ auto: true },
],
});

export default test;

0 comments on commit dc5ace2

Please sign in to comment.