Skip to content

Commit bbb9479

Browse files
committed
Add tests with Playwright
1 parent 7b9fac9 commit bbb9479

File tree

7 files changed

+143
-1
lines changed

7 files changed

+143
-1
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: Run Playwright tests
2+
on:
3+
issue_comment:
4+
types: [created, edited]
5+
6+
jobs:
7+
runs-on: ubuntu-latest
8+
if: contains(github.event.comment.html_url, '/pull/') && github.event.comment.user.login == 'netlify[bot]' && contains(github.event.comment.body, 'ready!')
9+
steps:
10+
- run: git config --global core.autocrlf input
11+
- uses: actions/checkout@v4
12+
with:
13+
fetch-depth: 0
14+
persist-credentials: false
15+
16+
- uses: actions/setup-node@v4
17+
with:
18+
node-version: '22'
19+
cache: 'yarn'
20+
21+
- name: Install dependencies
22+
run: yarn install --immutable
23+
24+
- name: Run tests
25+
env:
26+
PLAYWRIGHT_TEST_BASE_URL: https://deploy-preview-${{ github.event.issue.number }}--cambria-project.netlify.app
27+
run: yarn playwright test

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,9 @@ node_modules
1010
coverage/
1111
dist/
1212
docs/
13+
14+
# Playwright
15+
/test-results/
16+
/playwright-report/
17+
/blob-report/
18+
/playwright/.cache/

biome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
},
88
"files": {
99
"ignoreUnknown": false,
10-
"ignore": ["demo/", "dist/", "coverage/", ".nyc_output/"]
10+
"ignore": ["demo/", "dist/", "coverage/", ".nyc_output/", "docs/"]
1111
},
1212
"formatter": {
1313
"enabled": true,

e2e/demo.spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { expect, test } from "@playwright/test";
2+
3+
test("has input set correctly", async ({ page }) => {
4+
await page.goto("/demo/index.html");
5+
6+
await expect(
7+
page.locator("cambria-document").first().getByLabel("root[name]"),
8+
).toHaveValue(/The Fifth Element/);
9+
});

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"devDependencies": {
2323
"@biomejs/biome": "1.9.4",
2424
"@json-editor/json-editor": "2.6.1",
25+
"@playwright/test": "^1.51.1",
2526
"@types/graphlib": "^2.1.12",
2627
"@types/mocha": "^10.0.10",
2728
"@types/node": "^14.18.63",

playwright.config.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { defineConfig, devices } from "@playwright/test";
2+
3+
/**
4+
* See https://playwright.dev/docs/test-configuration.
5+
*/
6+
export default defineConfig({
7+
testDir: "./e2e",
8+
/* Run tests in files in parallel */
9+
fullyParallel: true,
10+
/* Fail the build on CI if you accidentally left test.only in the source code. */
11+
forbidOnly: !!process.env.CI,
12+
/* Retry on CI only */
13+
retries: process.env.CI ? 2 : 0,
14+
/* Opt out of parallel tests on CI. */
15+
workers: process.env.CI ? 1 : undefined,
16+
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
17+
reporter: "list",
18+
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
19+
use: {
20+
/* Base URL to use in actions like `await page.goto('/')`. */
21+
baseURL: process.env.PLAYWRIGHT_TEST_BASE_URL || "http://127.0.0.1:8080",
22+
23+
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
24+
trace: "on-first-retry",
25+
},
26+
27+
/* Configure projects for major browsers */
28+
projects: [
29+
{
30+
name: "chromium",
31+
use: { ...devices["Desktop Chrome"] },
32+
},
33+
34+
{
35+
name: "firefox",
36+
use: { ...devices["Desktop Firefox"] },
37+
},
38+
39+
{
40+
name: "webkit",
41+
use: { ...devices["Desktop Safari"] },
42+
},
43+
],
44+
});

yarn.lock

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,17 @@ __metadata:
436436
languageName: node
437437
linkType: hard
438438

439+
"@playwright/test@npm:^1.51.1":
440+
version: 1.51.1
441+
resolution: "@playwright/test@npm:1.51.1"
442+
dependencies:
443+
playwright: "npm:1.51.1"
444+
bin:
445+
playwright: cli.js
446+
checksum: 10/ffb0c964d54f593897f05a2587d8e1e4f5f0e8c28f5f6260c1182ff938eb375d96c57594dd2f223ec45452a6af40695fd22f222930610c32f345e28ccf53141d
447+
languageName: node
448+
linkType: hard
449+
439450
"@shikijs/engine-oniguruma@npm:^3.2.1":
440451
version: 3.2.1
441452
resolution: "@shikijs/engine-oniguruma@npm:3.2.1"
@@ -1137,6 +1148,7 @@ __metadata:
11371148
"@biomejs/biome": "npm:1.9.4"
11381149
"@dagrejs/graphlib": "npm:^2.1.8"
11391150
"@json-editor/json-editor": "npm:2.6.1"
1151+
"@playwright/test": "npm:^1.51.1"
11401152
"@types/graphlib": "npm:^2.1.12"
11411153
"@types/mocha": "npm:^10.0.10"
11421154
"@types/node": "npm:^14.18.63"
@@ -1960,6 +1972,16 @@ __metadata:
19601972
languageName: node
19611973
linkType: hard
19621974

1975+
"fsevents@npm:2.3.2":
1976+
version: 2.3.2
1977+
resolution: "fsevents@npm:2.3.2"
1978+
dependencies:
1979+
node-gyp: "npm:latest"
1980+
checksum: 10/6b5b6f5692372446ff81cf9501c76e3e0459a4852b3b5f1fc72c103198c125a6b8c72f5f166bdd76ffb2fca261e7f6ee5565daf80dca6e571e55bcc589cc1256
1981+
conditions: os=darwin
1982+
languageName: node
1983+
linkType: hard
1984+
19631985
"fsevents@npm:~2.3.2":
19641986
version: 2.3.3
19651987
resolution: "fsevents@npm:2.3.3"
@@ -1970,6 +1992,15 @@ __metadata:
19701992
languageName: node
19711993
linkType: hard
19721994

1995+
"fsevents@patch:fsevents@npm%3A2.3.2#optional!builtin<compat/fsevents>":
1996+
version: 2.3.2
1997+
resolution: "fsevents@patch:fsevents@npm%3A2.3.2#optional!builtin<compat/fsevents>::version=2.3.2&hash=df0bf1"
1998+
dependencies:
1999+
node-gyp: "npm:latest"
2000+
conditions: os=darwin
2001+
languageName: node
2002+
linkType: hard
2003+
19732004
"fsevents@patch:fsevents@npm%3A~2.3.2#optional!builtin<compat/fsevents>":
19742005
version: 2.3.3
19752006
resolution: "fsevents@patch:fsevents@npm%3A2.3.3#optional!builtin<compat/fsevents>::version=2.3.3&hash=df0bf1"
@@ -3521,6 +3552,30 @@ __metadata:
35213552
languageName: node
35223553
linkType: hard
35233554

3555+
"playwright-core@npm:1.51.1":
3556+
version: 1.51.1
3557+
resolution: "playwright-core@npm:1.51.1"
3558+
bin:
3559+
playwright-core: cli.js
3560+
checksum: 10/954ce25782bbf0780c170caa56e7a0ab2e625dad42c628f9ee684974398b93885e58b88afb8b18dd2c96a7a82c6dde474d4fa7a4f6dff32111a562506c187cc3
3561+
languageName: node
3562+
linkType: hard
3563+
3564+
"playwright@npm:1.51.1":
3565+
version: 1.51.1
3566+
resolution: "playwright@npm:1.51.1"
3567+
dependencies:
3568+
fsevents: "npm:2.3.2"
3569+
playwright-core: "npm:1.51.1"
3570+
dependenciesMeta:
3571+
fsevents:
3572+
optional: true
3573+
bin:
3574+
playwright: cli.js
3575+
checksum: 10/cc7d3e204b9fd70a7208ef1d189981135a04de533eff4a6772a6c8be1604a1eaaa3bac9129eb5d814384d4f727fb8011832676a5105b1b260917c48c421f7f9b
3576+
languageName: node
3577+
linkType: hard
3578+
35243579
"proc-log@npm:^5.0.0":
35253580
version: 5.0.0
35263581
resolution: "proc-log@npm:5.0.0"

0 commit comments

Comments
 (0)