Skip to content

Commit 7ebc0f8

Browse files
committed
Implement snapshots in Playwright
This could be used for visual regression testing
1 parent ab72a50 commit 7ebc0f8

File tree

62 files changed

+98
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+98
-1
lines changed

playwright.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const dotenv = require('dotenv');
44
const testDir = './tests/e2e';
55
const envFile = process.env.CI ? `${testDir}/env/.env.ci` : `${testDir}/env/.env.default`;
66
dotenv.config({path: envFile});
7-
dotenv.config({override: true});// prioritize .env file if exists
7+
dotenv.config({override: true}); // prioritize .env file if exists
88

99
/**
1010
* @see https://playwright.dev/docs/test-configuration
@@ -113,6 +113,7 @@ const config = {
113113
// command: 'npm run start',
114114
// port: 3000,
115115
// },
116+
globalSetup: require.resolve('./tests/e2e/tools/setup/global-setup'),
116117
};
117118

118119
module.exports = config;

tests/e2e/snapshots.spec.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import {test, expect} from './tools/lib/test-utils.js';
2+
import {readSiteMap} from './tools/setup/sitemap.js';
3+
4+
test('Snapshots', async ({page}) => {
5+
const urls = await readSiteMap();
6+
for (const url of urls) {
7+
await page.goto(url);
8+
await expect(page).toHaveScreenshot();
9+
}
10+
});
803 KB
1.06 MB
1.03 MB
111 KB
153 KB
140 KB
87.5 KB
121 KB

0 commit comments

Comments
 (0)