Skip to content

Commit ad465b8

Browse files
committed
test: set up screenshot testing for docs.page
1 parent 2a66730 commit ad465b8

File tree

10 files changed

+1378
-4245
lines changed

10 files changed

+1378
-4245
lines changed

.github/workflows/playwright.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Playwright Tests
2+
on:
3+
push:
4+
branches: [ main, master ]
5+
pull_request:
6+
branches: [ main, master ]
7+
jobs:
8+
test:
9+
timeout-minutes: 60
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
- uses: actions/setup-node@v3
14+
with:
15+
node-version: 16
16+
- name: Install dependencies
17+
run: yarn
18+
- name: Install Playwright Browsers
19+
run: npx playwright install --with-deps
20+
- name: Run Playwright tests
21+
run: yarn playwright test
22+
- uses: actions/upload-artifact@v3
23+
if: always()
24+
with:
25+
name: playwright-report
26+
path: playwright-report/
27+
retention-days: 30

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,6 @@ tailwind.css*
3939

4040
# Tests
4141
website/tests/screenshots/*
42+
/test-results/
43+
/playwright-report/
44+
/playwright/.cache/

__tests__/config.test.ts

Lines changed: 0 additions & 41 deletions
This file was deleted.

__tests__/index.test.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

__tests__/utils.test.ts

Lines changed: 0 additions & 99 deletions
This file was deleted.

domains.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@
77
"melos.invertase.dev",
88
"invertase/melos"
99
],
10-
[
11-
"melos.invertase.io",
12-
"invertase/melos"
13-
],
1410
[
1511
"extensions.invertase.dev",
1612
"invertase/firebase-extensions"
@@ -20,7 +16,7 @@
2016
"invertase/react-query-firebase"
2117
],
2218
[
23-
"docs.flexcolorscheme.com",
19+
"docs.flexcolorscheme.com",
2420
"rydmike/flex_color_scheme_docs"
2521
],
2622
[

package.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
{
22
"private": true,
3-
"workspaces": [
4-
"website",
5-
"packages/*",
6-
"api"
7-
],
83
"scripts": {
94
"dev": "concurrently \"yarn dev:api\" \"yarn dev:website\"",
105
"dev:website": "cd website && yarn dev",
@@ -19,6 +14,7 @@
1914
"typescript": "^4.5.4"
2015
},
2116
"devDependencies": {
17+
"@playwright/test": "^1.27.1",
2218
"@typescript-eslint/eslint-plugin": "^5.9.1",
2319
"@typescript-eslint/parser": "^5.9.1",
2420
"concurrently": "^7.0.0",

playwright.config.ts

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
import type { PlaywrightTestConfig } from '@playwright/test';
2+
import { devices } from '@playwright/test';
3+
4+
/**
5+
* Read environment variables from file.
6+
* https://github.com/motdotla/dotenv
7+
*/
8+
// require('dotenv').config();
9+
10+
/**
11+
* See https://playwright.dev/docs/test-configuration.
12+
*/
13+
const config: PlaywrightTestConfig = {
14+
testDir: './__tests__',
15+
/* Maximum time one test can run for. */
16+
timeout: 30 * 1000,
17+
expect: {
18+
/**
19+
* Maximum time expect() should wait for the condition to be met.
20+
* For example in `await expect(locator).toHaveText();`
21+
*/
22+
timeout: 5000
23+
},
24+
/* Run tests in files in parallel */
25+
fullyParallel: true,
26+
/* Fail the build on CI if you accidentally left test.only in the source code. */
27+
forbidOnly: !!process.env.CI,
28+
/* Retry on CI only */
29+
retries: process.env.CI ? 2 : 0,
30+
/* Opt out of parallel tests on CI. */
31+
workers: process.env.CI ? 1 : undefined,
32+
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
33+
reporter: 'html',
34+
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
35+
use: {
36+
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
37+
actionTimeout: 0,
38+
/* Base URL to use in actions like `await page.goto('/')`. */
39+
// baseURL: 'http://localhost:3000',
40+
41+
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
42+
trace: 'on-first-retry',
43+
},
44+
45+
/* Configure projects for major browsers */
46+
projects: [
47+
{
48+
name: 'chromium',
49+
use: {
50+
...devices['Desktop Chrome'],
51+
},
52+
}
53+
54+
/* Test against mobile viewports. */
55+
// {
56+
// name: 'Mobile Chrome',
57+
// use: {
58+
// ...devices['Pixel 5'],
59+
// },
60+
// },
61+
// {
62+
// name: 'Mobile Safari',
63+
// use: {
64+
// ...devices['iPhone 12'],
65+
// },
66+
// },
67+
68+
/* Test against branded browsers. */
69+
// {
70+
// name: 'Microsoft Edge',
71+
// use: {
72+
// channel: 'msedge',
73+
// },
74+
// },
75+
// {
76+
// name: 'Google Chrome',
77+
// use: {
78+
// channel: 'chrome',
79+
// },
80+
// },
81+
],
82+
83+
/* Folder for test artifacts such as screenshots, videos, traces, etc. */
84+
// outputDir: 'test-results/',
85+
86+
/* Run your local dev server before starting the tests */
87+
// webServer: {
88+
// command: 'npm run start',
89+
// port: 3000,
90+
// },
91+
};
92+
93+
export default config;

0 commit comments

Comments
 (0)