Skip to content

Commit d7b8696

Browse files
committed
Add Playwright
1 parent 2679339 commit d7b8696

File tree

17 files changed

+373
-20
lines changed

17 files changed

+373
-20
lines changed

.github/actions/build-core/action.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
name: Build core
2+
description: Build the core package
3+
runs:
4+
using: composite
5+
steps:
6+
- shell: bash
7+
run: pnpm core:build
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
name: Build Svelte
2+
description: Build the Svelte wrapper
3+
runs:
4+
using: composite
5+
steps:
6+
- uses: ./.github/actions/build-core
7+
- shell: bash
8+
run: pnpm svelte:build

.github/actions/build-vue/action.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
name: Build Vue
2+
description: Build the Vue wrapper
3+
runs:
4+
using: composite
5+
steps:
6+
- uses: ./.github/actions/build-core
7+
- shell: bash
8+
run: pnpm vue:build
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Install dependencies
2+
description: Install with cached dependencies
3+
runs:
4+
using: composite
5+
steps:
6+
- uses: actions/setup-node@v3
7+
with:
8+
node-version: 18
9+
- uses: pnpm/action-setup@v2.4.0
10+
with:
11+
run_install: false
12+
version: 8
13+
- shell: bash
14+
run: echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
15+
- uses: actions/cache@v3
16+
with:
17+
key: v1-${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
18+
path: ${{ env.STORE_PATH }}
19+
restore-keys: v1-${{ runner.os }}-pnpm-store-
20+
- shell: bash
21+
run: pnpm install

.github/workflows/ci.yml

+49-7
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,55 @@ on:
55
branches:
66
- main
77
jobs:
8-
check:
8+
build-core:
99
runs-on: ubuntu-latest
1010
steps:
1111
- uses: actions/checkout@v3
12-
- uses: actions/setup-node@v3
13-
with:
14-
node-version: 16
15-
- uses: pnpm/action-setup@v2
16-
- run: pnpm install
17-
- run: pnpm run ci
12+
- uses: ./.github/actions/install-dependencies
13+
- uses: ./.github/actions/build-core
14+
build-svelte:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v3
18+
- uses: ./.github/actions/install-dependencies
19+
- uses: ./.github/actions/build-core
20+
- uses: ./.github/actions/build-svelte
21+
build-vue:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v3
25+
- uses: ./.github/actions/install-dependencies
26+
- uses: ./.github/actions/build-core
27+
- uses: ./.github/actions/build-vue
28+
check-docs:
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v3
32+
- uses: ./.github/actions/install-dependencies
33+
- run: pnpm -r docs:check
34+
lint:
35+
runs-on: ubuntu-latest
36+
steps:
37+
- uses: actions/checkout@v3
38+
- uses: ./.github/actions/install-dependencies
39+
- run: pnpm -r lint
40+
test-e2e:
41+
runs-on: ubuntu-latest
42+
steps:
43+
- uses: actions/checkout@v3
44+
- uses: ./.github/actions/install-dependencies
45+
- run: pnpm playwright install --with-deps
46+
- run: pnpm -r test:e2e
47+
test-unit:
48+
runs-on: ubuntu-latest
49+
steps:
50+
- uses: actions/checkout@v3
51+
- uses: ./.github/actions/install-dependencies
52+
- run: pnpm -r test:unit
53+
typecheck:
54+
runs-on: ubuntu-latest
55+
steps:
56+
- uses: actions/checkout@v3
57+
- uses: ./.github/actions/install-dependencies
58+
- uses: ./.github/actions/build-core
59+
- run: pnpm typecheck

.github/workflows/publish.yml

+4-6
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@ jobs:
88
runs-on: ubuntu-latest
99
steps:
1010
- uses: actions/checkout@v3
11-
- uses: actions/setup-node@v3
12-
with:
13-
node-version: 16
14-
- uses: pnpm/action-setup@v2
15-
- run: pnpm install
16-
- run: pnpm run ci
11+
- uses: ./.github/actions/install-dependencies
12+
- uses: ./.github/actions/build-core
13+
- uses: ./.github/actions/build-svelte
14+
- uses: ./.github/actions/build-vue
1715
- run: pnpm config set '//registry.npmjs.org/:_authToken' ${{ secrets.NPM_PUBLISH_TOKEN }}
1816
- run: pnpm publish --access public --no-git-checks

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,9 @@
33
dist
44
node_modules
55
tmp
6+
7+
# Playwright
8+
/test-results/
9+
/playwright-report/
10+
/blob-report/
11+
/playwright/.cache/

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@
8888
"build": "run-s core:build && run-p svelte:build vue:build",
8989
"ci": "run-p ci:*",
9090
"ci:build": "run-s build",
91-
"ci:test": "run-s test:once",
9291
"ci:lint": "run-s lint",
9392
"ci:docs": "run-s docs:check",
9493
"ci:dedupe": "pnpm dedupe --use-stderr",
@@ -109,7 +108,8 @@
109108
"svelte:build": "run-s svelte:clean && pnpm --filter svelte build",
110109
"svelte:clean": "rimraf ./svelte/dist",
111110
"test": "run-s test:watch",
112-
"test:once": "vitest run",
111+
"test:e2e": "playwright test",
112+
"test:unit": "vitest run",
113113
"test:watch": "vitest",
114114
"typecheck": "run-p core:typecheck vue:typecheck",
115115
"vue:build": "run-s vue:clean && run-p vue:typecheck vue:build:*",
@@ -151,6 +151,7 @@
151151
"style-mod": "^4.1.2"
152152
},
153153
"devDependencies": {
154+
"@playwright/test": "^1.42.1",
154155
"@rollup/plugin-alias": "^5.1.0",
155156
"@types/express": "^4.17.21",
156157
"@types/katex": "^0.16.7",

playwright.config.ts

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import { defineConfig, devices } from '@playwright/test'
2+
3+
/**
4+
* Read environment variables from file.
5+
* https://github.com/motdotla/dotenv
6+
*/
7+
// require('dotenv').config();
8+
9+
/**
10+
* See https://playwright.dev/docs/test-configuration.
11+
*/
12+
export default defineConfig({
13+
testDir: './test/e2e',
14+
/* Run tests in files in parallel */
15+
fullyParallel: true,
16+
/* Fail the build on CI if you accidentally left test.only in the source code. */
17+
forbidOnly: !!process.env.CI,
18+
/* Retry on CI only */
19+
retries: process.env.CI ? 2 : 0,
20+
/* Opt out of parallel tests on CI. */
21+
workers: process.env.CI ? 1 : undefined,
22+
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
23+
reporter: 'html',
24+
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
25+
use: {
26+
/* Base URL to use in actions like `await page.goto('/')`. */
27+
baseURL: process.env.BASE_URL || 'http://localhost:5173',
28+
29+
testIdAttribute: 'data-test-id',
30+
31+
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
32+
trace: 'on-first-retry',
33+
video: 'retain-on-failure',
34+
},
35+
36+
/* Configure projects for major browsers */
37+
projects: [
38+
{
39+
name: 'chromium',
40+
use: { ...devices['Desktop Chrome'] },
41+
},
42+
43+
{
44+
name: 'firefox',
45+
use: { ...devices['Desktop Firefox'] },
46+
},
47+
48+
{
49+
name: 'webkit',
50+
use: { ...devices['Desktop Safari'] },
51+
},
52+
53+
/* Test against mobile viewports. */
54+
// {
55+
// name: 'Mobile Chrome',
56+
// use: { ...devices['Pixel 5'] },
57+
// },
58+
// {
59+
// name: 'Mobile Safari',
60+
// use: { ...devices['iPhone 12'] },
61+
// },
62+
63+
/* Test against branded browsers. */
64+
// {
65+
// name: 'Microsoft Edge',
66+
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
67+
// },
68+
// {
69+
// name: 'Google Chrome',
70+
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
71+
// },
72+
],
73+
74+
/* Run your local dev server before starting the tests */
75+
webServer: {
76+
command: 'pnpm dev',
77+
url: 'http://localhost:5173',
78+
reuseExistingServer: !process.env.CI,
79+
},
80+
})

pnpm-lock.yaml

+35
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
packages:
2-
- examples/*
3-
- svelte
2+
- .
3+
- ./examples/*
4+
- ./svelte

test/e2e/index.html

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!doctype html>
2+
<html class="auto">
3+
<head>
4+
<meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=0">
5+
<title>E2E Tests</title>
6+
</head>
7+
<body>
8+
<div id="editor"></div>
9+
</body>
10+
</html>

0 commit comments

Comments
 (0)