Skip to content

Commit 577c6ca

Browse files
committed
feat: integrate playwright
1 parent 99f0cc1 commit 577c6ca

File tree

8 files changed

+14882
-0
lines changed

8 files changed

+14882
-0
lines changed

.github/workflows/playwright.yml

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

app/env.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export default defineConfig({
1515
}
1616
return value as ('production' | 'staging' | 'testing' | `alpha-${number}` | 'development' | 'APP_ENVIRONMENT_PLACEHOLDER');
1717
},
18+
APP_BASE_URL: Schema.string.optional(),
1819
APP_API_ENDPOINT: Schema.string({ format: 'url', protocol: true, tld: false }),
1920
APP_ADMIN_URL: Schema.string.optional({ format: 'url', protocol: true }),
2021
APP_MAPBOX_ACCESS_TOKEN: Schema.string(),

packages/tests-e2e/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules/
2+
/test-results/
3+
/playwright-report/
4+
/blob-report/
5+
/playwright/.cache/

packages/tests-e2e/package.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "tests-e2e",
3+
"version": "1.0.0",
4+
"main": "index.js",
5+
"license": "MIT",
6+
"devDependencies": {
7+
"@playwright/test": "^1.44.0",
8+
"@types/node": "^20.12.12"
9+
},
10+
"scripts": {},
11+
"dependencies": {
12+
"dotenv": "^16.4.5"
13+
}
14+
}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
import { defineConfig, devices } from '@playwright/test';
2+
import 'dotenv/config';
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+
export default defineConfig({
14+
testDir: './tests',
15+
/* Run tests in files in parallel */
16+
fullyParallel: true,
17+
/* Fail the build on CI if you accidentally left test.only in the source code. */
18+
forbidOnly: !!process.env.CI,
19+
/* Retry on CI only */
20+
retries: process.env.CI ? 2 : 0,
21+
/* Opt out of parallel tests on CI. */
22+
workers: process.env.CI ? 1 : undefined,
23+
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
24+
reporter: 'html',
25+
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
26+
use: {
27+
/* Base URL to use in actions like `await page.goto('/')`. */
28+
baseURL: process.env.APP_BASE_URL,
29+
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
30+
trace: 'on-first-retry',
31+
},
32+
33+
/* Configure projects for major browsers */
34+
projects: process.env.CI ? [
35+
{
36+
name: 'chromium',
37+
use: { ...devices['Desktop Chrome'] },
38+
},
39+
40+
{
41+
name: 'firefox',
42+
use: { ...devices['Desktop Firefox'] },
43+
},
44+
45+
{
46+
name: 'webkit',
47+
use: { ...devices['Desktop Safari'] },
48+
},
49+
50+
/* Test against mobile viewports. */
51+
// {
52+
// name: 'Mobile Chrome',
53+
// use: { ...devices['Pixel 5'] },
54+
// },
55+
// {
56+
// name: 'Mobile Safari',
57+
// use: { ...devices['iPhone 12'] },
58+
// },
59+
60+
/* Test against branded browsers. */
61+
// {
62+
// name: 'Microsoft Edge',
63+
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
64+
// },
65+
// {
66+
// name: 'Google Chrome',
67+
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
68+
// },
69+
] : [
70+
// NOTE: WebKit is only supported on Debian and Ubuntu in Playwright.
71+
{
72+
name: 'chromium',
73+
use: { ...devices['Desktop Chrome'] },
74+
},
75+
76+
{
77+
name: 'firefox',
78+
use: { ...devices['Desktop Firefox'] },
79+
},
80+
],
81+
82+
/* Run your local dev server before starting the tests */
83+
// webServer: {
84+
// command: 'npm run start',
85+
// url: 'http://127.0.0.1:3000',
86+
// reuseExistingServer: !process.env.CI,
87+
// },
88+
});

0 commit comments

Comments
 (0)