Skip to content

Commit 71d83d0

Browse files
committed
WIP: Add Playwright tests
1 parent 6fdec25 commit 71d83d0

File tree

7 files changed

+413
-14
lines changed

7 files changed

+413
-14
lines changed

.github/workflows/playwright.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Playwright Tests
2+
on: [pull_request, workflow_dispatch]
3+
jobs:
4+
test:
5+
timeout-minutes: 60
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@v4
9+
- uses: actions/setup-node@v4
10+
with:
11+
node-version: lts/*
12+
- name: Install dependencies
13+
run: npm ci
14+
- name: Install Playwright Browsers
15+
run: npx playwright install --with-deps
16+
- name: Run Playwright tests
17+
run: npx playwright test
18+
env:
19+
PASSWORD: ${{ secrets.PASSWORD }}
20+
- uses: actions/upload-artifact@v4
21+
if: ${{ !cancelled() }}
22+
with:
23+
name: playwright-report
24+
path: playwright-report/
25+
retention-days: 30

.gitignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
.DS_Store
2-
cypress.env.json
2+
33
node_modules/
4+
5+
cypress.env.json
46
cypress/downloads/
57
cypress/screenshots/
68
cypress/videos/
9+
10+
test-results/
11+
playwright-report/
12+
blob-report/
13+
playwright/.cache/

package-lock.json

Lines changed: 78 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"cy:open:prod": "cypress open --env environment=prod",
99
"test": "cypress run --record false --browser chrome",
1010
"test:prod": "cypress run --record false --browser chrome --env environment=prod",
11-
"test:prod:cloud": "cypress run --browser chrome --record --tag 'prod' --env environment=prod"
11+
"test:prod:cloud": "cypress run --browser chrome --record --tag 'prod' --env environment=prod",
12+
"pw:open": "PASSWORD='53cR37P@55w0rD' playwright test --ui"
1213
},
1314
"keywords": [
1415
"Cypress Playground",
@@ -20,8 +21,11 @@
2021
"author": "Walmyr <[email protected]> (https://walmyr.dev/)",
2122
"license": "MIT",
2223
"devDependencies": {
24+
"@playwright/test": "^1.49.1",
25+
"@types/node": "^22.10.2",
2326
"axe-core": "^4.10.2",
2427
"cypress": "^13.17.0",
25-
"cypress-axe": "^1.5.0"
28+
"cypress-axe": "^1.5.0",
29+
"lodash": "^4.17.21"
2630
}
2731
}

playwright.config.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// @ts-check
2+
const { defineConfig, devices } = require('@playwright/test')
3+
4+
/**
5+
* Read environment variables from file.
6+
* https://github.com/motdotla/dotenv
7+
*/
8+
// require('dotenv').config({ path: path.resolve(__dirname, '.env') })
9+
10+
/**
11+
* @see https://playwright.dev/docs/test-configuration
12+
*/
13+
module.exports = 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: 'http://127.0.0.1:3000',
29+
30+
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
31+
trace: 'on-first-retry',
32+
},
33+
34+
/* Configure projects for major browsers */
35+
projects: [
36+
{
37+
name: 'chromium',
38+
use: { ...devices['Desktop Chrome'] },
39+
},
40+
],
41+
})
42+

tests/example.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Hello, World!

0 commit comments

Comments
 (0)