Skip to content

Commit f977427

Browse files
authored
test: playwright testing for playground builds (#29)
1 parent 74b61d9 commit f977427

File tree

8 files changed

+525
-303
lines changed

8 files changed

+525
-303
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ create.cjs
55
**/web-extension/
66
.pnpm-debug.log
77
/playground/
8+
/test-results/
9+
/playwright-report/
10+
/playwright/.cache/

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@
1313
"engines": {
1414
"node": "^14.13.1 || >=16.0.0"
1515
},
16-
"packageManager": "pnpm@7.6.0",
16+
"packageManager": "pnpm@8.3.0",
1717
"scripts": {
1818
"build": "esbuild --bundle index.js --format=cjs --platform=node --outfile=create.cjs",
1919
"build:playground": "node scripts/build-playground.mjs",
2020
"lint": "prettier --write .",
2121
"prepare": "husky install",
22-
"release": "standard-version --sign"
22+
"release": "standard-version --sign",
23+
"test:playground": "playwright test",
24+
"test:playground:ui": "pnpm run test:playground --ui"
2325
},
2426
"standard-version": {
2527
"scripts": {
@@ -60,6 +62,8 @@
6062
"prompts": "^2.4.2"
6163
},
6264
"devDependencies": {
65+
"@playwright/test": "^1.32.3",
66+
"@types/node": "^18.15.11",
6367
"esbuild": "^0.14.11",
6468
"husky": "^8.0.2",
6569
"lint-staged": "^13.1.0",

playwright.config.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { defineConfig, devices } from "@playwright/test";
2+
import path from "path";
3+
import { fileURLToPath } from "url";
4+
import { TestOptions, getDirectories } from "./tests/e2e/fixtures.ts";
5+
6+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
7+
8+
const playgroundDir = path.join(__dirname, "playground");
9+
const playgroundBuilds = await getDirectories(playgroundDir);
10+
11+
export default defineConfig<TestOptions>({
12+
testDir: "./tests/e2e",
13+
fullyParallel: true,
14+
forbidOnly: !!process.env.CI,
15+
retries: process.env.CI ? 2 : 0,
16+
workers: process.env.CI ? 1 : undefined,
17+
reporter: process.env.CI ? "dot" : "list",
18+
use: {
19+
trace: "on-first-retry",
20+
},
21+
22+
projects: playgroundBuilds.map((playgroundBuild) => ({
23+
name: playgroundBuild,
24+
use: {
25+
...devices["Desktop Chrome"],
26+
extensionPath: path.join(`${playgroundDir}/${playgroundBuild}/dist`),
27+
},
28+
})),
29+
});

0 commit comments

Comments
 (0)