Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Playwright config update, move snapshots to their own folder #1334

Merged
merged 3 commits into from
Mar 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;