Skip to content

Commit

Permalink
chore: update playwright snapshot config
Browse files Browse the repository at this point in the history
  • Loading branch information
renrizzolo committed Feb 29, 2024
1 parent d11976c commit c2f48be
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
13 changes: 10 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,9 @@ 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}{-projectName}{ext}',
use: {
browserName: 'chromium',
channel: 'chrome',
Expand All @@ -52,6 +59,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 c2f48be

Please sign in to comment.