playwright-toolbox 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/.changeset/README.md +9 -0
  2. package/.changeset/config.json +11 -0
  3. package/README.md +90 -0
  4. package/package.json +26 -0
  5. package/packages/playwright-config/CHANGELOG.md +21 -0
  6. package/packages/playwright-config/README.md +22 -0
  7. package/packages/playwright-config/package.json +47 -0
  8. package/packages/playwright-config/src/index.ts +21 -0
  9. package/packages/playwright-config/tsconfig.json +19 -0
  10. package/packages/playwright-history-dashboard/CHANGELOG.md +21 -0
  11. package/packages/playwright-history-dashboard/README.md +216 -0
  12. package/packages/playwright-history-dashboard/RELEASING.md +249 -0
  13. package/packages/playwright-history-dashboard/dashboard/index.html +2825 -0
  14. package/packages/playwright-history-dashboard/package-lock.json +105 -0
  15. package/packages/playwright-history-dashboard/package.json +56 -0
  16. package/packages/playwright-history-dashboard/pw-dashboard.config.js +22 -0
  17. package/packages/playwright-history-dashboard/scripts/init.ts +95 -0
  18. package/packages/playwright-history-dashboard/src/reporter.ts +376 -0
  19. package/packages/playwright-history-dashboard/tsconfig.json +19 -0
  20. package/packages/pw-standard/.eslintrc.js +23 -0
  21. package/packages/pw-standard/CHANGELOG.md +31 -0
  22. package/packages/pw-standard/README.md +50 -0
  23. package/packages/pw-standard/jest.config.js +28 -0
  24. package/packages/pw-standard/package.json +86 -0
  25. package/packages/pw-standard/src/base/index.ts +19 -0
  26. package/packages/pw-standard/src/eslint/index.ts +91 -0
  27. package/packages/pw-standard/src/eslint/rules/no-brittle-selectors.ts +53 -0
  28. package/packages/pw-standard/src/eslint/rules/no-focused-tests.ts +61 -0
  29. package/packages/pw-standard/src/eslint/rules/no-page-pause.ts +37 -0
  30. package/packages/pw-standard/src/eslint/rules/no-wait-for-timeout.ts +34 -0
  31. package/packages/pw-standard/src/eslint/rules/prefer-web-first-assertions.ts +90 -0
  32. package/packages/pw-standard/src/eslint/rules/require-test-description.ts +159 -0
  33. package/packages/pw-standard/src/eslint/types.ts +20 -0
  34. package/packages/pw-standard/src/eslint/utils/ast.ts +59 -0
  35. package/packages/pw-standard/src/index.ts +13 -0
  36. package/packages/pw-standard/src/playwright/index.ts +6 -0
  37. package/packages/pw-standard/src/tsconfig/base.json +21 -0
  38. package/packages/pw-standard/src/tsconfig/strict.json +11 -0
  39. package/packages/pw-standard/tests/eslint/no-brittle-selectors.test.ts +34 -0
  40. package/packages/pw-standard/tests/eslint/no-page-pause-and-focused.test.ts +41 -0
  41. package/packages/pw-standard/tests/eslint/no-wait-for-timeout.test.ts +30 -0
  42. package/packages/pw-standard/tests/eslint/prefer-web-first-assertions.test.ts +25 -0
  43. package/packages/pw-standard/tests/eslint/require-test-description.test.ts +49 -0
  44. package/packages/pw-standard/tsconfig.json +24 -0
@@ -0,0 +1,9 @@
1
+ # Changesets
2
+
3
+ This directory stores release notes for independent package versioning.
4
+
5
+ Workflow:
6
+
7
+ 1. `npm run changeset`
8
+ 2. `npm run version-packages`
9
+ 3. `npm run release`
@@ -0,0 +1,11 @@
1
+ {
2
+ "$schema": "https://unpkg.com/@changesets/config@3.0.0/schema.json",
3
+ "changelog": "@changesets/cli/changelog",
4
+ "commit": false,
5
+ "fixed": [],
6
+ "linked": [],
7
+ "access": "public",
8
+ "baseBranch": "main",
9
+ "updateInternalDependencies": "patch",
10
+ "ignore": []
11
+ }
package/README.md ADDED
@@ -0,0 +1,90 @@
1
+ # Playwright Toolbox Monorepo
2
+
3
+ This repository is an npm workspaces monorepo with three independent packages:
4
+
5
+ 1. `@acahet/pw-standard`
6
+ 2. `@acahet/playwright-config`
7
+ 3. `@acahet/playwright-history-dashboard`
8
+
9
+ ## Workspace layout
10
+
11
+ - `packages/pw-standard`
12
+ - `packages/playwright-config`
13
+ - `packages/playwright-history-dashboard`
14
+
15
+ ## Package usage
16
+
17
+ ### 1) @acahet/pw-standard
18
+
19
+ Use for Playwright ESLint rules, base abstractions, and tsconfig presets.
20
+
21
+ ```bash
22
+ npm i -D @acahet/pw-standard
23
+ ```
24
+
25
+ ### 2) @acahet/playwright-config
26
+
27
+ Use for extracted Playwright config presets.
28
+
29
+ ```bash
30
+ npm i -D @acahet/playwright-config
31
+ ```
32
+
33
+ ### 3) @acahet/playwright-history-dashboard
34
+
35
+ Use for local run history tracking and static dashboard visualization.
36
+
37
+ ```bash
38
+ npm i -D @acahet/playwright-history-dashboard
39
+ ```
40
+
41
+ See package-specific docs:
42
+
43
+ - `packages/pw-standard/README.md`
44
+ - `packages/playwright-config/README.md`
45
+ - `packages/playwright-history-dashboard/README.md`
46
+
47
+ ## Local development
48
+
49
+ Run from monorepo root:
50
+
51
+ ```bash
52
+ npm install
53
+ npm run build
54
+ npm test
55
+ npm run lint
56
+ ```
57
+
58
+ ## Independent versioning and release
59
+
60
+ Changesets is configured for independent package versioning.
61
+
62
+ ```bash
63
+ npm run changeset
64
+ npm run version-packages
65
+ npm run release
66
+ ```
67
+
68
+ ## Migration notes
69
+
70
+ ### Import migration
71
+
72
+ - Previous: `@acahet/pw-standard/playwright`
73
+ - New preferred: `@acahet/playwright-config`
74
+ - Compatibility: `@acahet/pw-standard/playwright` is still re-exported for transition safety.
75
+
76
+ ### Folder migration
77
+
78
+ - Previous rules source: `playwright-rules/src`
79
+ - New rules source: `packages/pw-standard/src`
80
+
81
+ - Previous rules tests: `playwright-rules/tests`
82
+ - New rules tests: `packages/pw-standard/tests`
83
+
84
+ - Previous dashboard folder: `playwright-history-dashboard/`
85
+ - New dashboard folder: `packages/playwright-history-dashboard/`
86
+
87
+ ### Release migration
88
+
89
+ - Previous root package publish model: one publishable root package plus one nested package.
90
+ - New model: three independent workspace packages with Changesets-managed versioning.
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "playwright-toolbox",
3
+ "private": false,
4
+ "version": "1.0.0",
5
+ "description": "Workspace monorepo for Playwright packages",
6
+ "workspaces": [
7
+ "packages/*"
8
+ ],
9
+ "scripts": {
10
+ "build": "npm run --workspaces --if-present build",
11
+ "build:watch": "npm run --workspaces --if-present build:watch",
12
+ "test": "npm run --workspaces --if-present test",
13
+ "test:watch": "npm run --workspaces --if-present test:watch",
14
+ "test:coverage": "npm run --workspaces --if-present test:coverage",
15
+ "lint": "npm run --workspaces --if-present lint",
16
+ "changeset": "changeset",
17
+ "version-packages": "changeset version",
18
+ "release": "changeset publish"
19
+ },
20
+ "devDependencies": {
21
+ "@changesets/cli": "^2.27.8"
22
+ },
23
+ "engines": {
24
+ "node": ">=18.0.0"
25
+ }
26
+ }
@@ -0,0 +1,21 @@
1
+ # @acahet/playwright-config
2
+
3
+ ## 1.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 51cd994: feat: publish history dashboard to npm, extract playwright-config as standalone package, add missing .eslintrc.js to pw-standard
8
+
9
+ ## 1.1.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 4329be3: Convert repository to npm workspaces with three independent packages and introduce `@acahet/playwright-config`.
14
+
15
+ Summary:
16
+
17
+ - migrate to `packages/*` workspace structure
18
+ - split Playwright config into dedicated package
19
+ - keep a compatibility bridge export at `@acahet/pw-standard/playwright`
20
+ - update dashboard package metadata/docs for new workspace location
21
+ - add root orchestration scripts and Changesets configuration
@@ -0,0 +1,22 @@
1
+ # @acahet/playwright-config
2
+
3
+ Shared Playwright config presets package.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm i -D @acahet/playwright-config
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```ts
14
+ import { defineConfig } from '@playwright/test';
15
+ import * as preset from '@acahet/playwright-config';
16
+
17
+ export default defineConfig({
18
+ ...preset,
19
+ });
20
+ ```
21
+
22
+ This package currently exports a placeholder root preset entry and is ready for incremental config extraction.
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@acahet/playwright-config",
3
+ "version": "1.2.0",
4
+ "description": "Shared Playwright config presets",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./dist/index.js",
10
+ "require": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "README.md"
17
+ ],
18
+ "scripts": {
19
+ "build": "tsc --project tsconfig.json",
20
+ "build:watch": "tsc --project tsconfig.json --watch",
21
+ "prepublishOnly": "npm run build"
22
+ },
23
+ "keywords": [
24
+ "playwright",
25
+ "playwright-config",
26
+ "testing",
27
+ "e2e",
28
+ "typescript"
29
+ ],
30
+ "author": "",
31
+ "license": "MIT",
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "git+https://github.com/acahet-automation-org/playwright-toolbox.git",
35
+ "directory": "packages/playwright-config"
36
+ },
37
+ "peerDependencies": {
38
+ "@playwright/test": ">=1.40.0"
39
+ },
40
+ "devDependencies": {
41
+ "@playwright/test": "^1.58.2",
42
+ "typescript": "^5.9.3"
43
+ },
44
+ "engines": {
45
+ "node": ">=18.0.0"
46
+ }
47
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @acahet/playwright-config
3
+ *
4
+ * Shared Playwright config presets.
5
+ *
6
+ * Usage in a consuming project's playwright.config.ts:
7
+ *
8
+ * import { baseConfig } from '@acahet/playwright-config';
9
+ * import { defineConfig } from '@playwright/test';
10
+ *
11
+ * export default defineConfig({
12
+ * ...baseConfig,
13
+ * use: { ...baseConfig.use, baseURL: 'http://localhost:3000' },
14
+ * });
15
+ */
16
+
17
+ // Configs will be added here — e.g.:
18
+ // export { baseConfig } from './base.config';
19
+ // export { ciConfig } from './ci.config';
20
+
21
+ export {};
@@ -0,0 +1,19 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "commonjs",
5
+ "lib": ["ES2020"],
6
+ "declaration": true,
7
+ "declarationMap": true,
8
+ "sourceMap": true,
9
+ "outDir": "./dist",
10
+ "rootDir": "./src",
11
+ "strict": true,
12
+ "esModuleInterop": true,
13
+ "skipLibCheck": true,
14
+ "forceConsistentCasingInFileNames": true,
15
+ "resolveJsonModule": true
16
+ },
17
+ "include": ["src/**/*"],
18
+ "exclude": ["node_modules", "dist"]
19
+ }
@@ -0,0 +1,21 @@
1
+ # @acahet/playwright-history-dashboard
2
+
3
+ ## 2.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - 51cd994: feat: publish history dashboard to npm, extract playwright-config as standalone package, add missing .eslintrc.js to pw-standard
8
+
9
+ ## 1.0.1
10
+
11
+ ### Patch Changes
12
+
13
+ - 4329be3: Convert repository to npm workspaces with three independent packages and introduce `@acahet/playwright-config`.
14
+
15
+ Summary:
16
+
17
+ - migrate to `packages/*` workspace structure
18
+ - split Playwright config into dedicated package
19
+ - keep a compatibility bridge export at `@acahet/pw-standard/playwright`
20
+ - update dashboard package metadata/docs for new workspace location
21
+ - add root orchestration scripts and Changesets configuration
@@ -0,0 +1,216 @@
1
+ # @acahet/playwright-history-dashboard
2
+
3
+ A self-hosted Playwright test history dashboard — no SaaS, no subscriptions, no external services. A custom reporter writes a local JSON index after every run, and a single-file HTML dashboard reads it directly from disk.
4
+
5
+ In this workspace, the package source is located at `package/packages/playwright-history-dashboard`.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install -D @acahet/playwright-history-dashboard
11
+ ```
12
+
13
+ ## Quick start
14
+
15
+ ### 1. Configure (optional but recommended)
16
+
17
+ Create `pw-dashboard.config.js` in your project root:
18
+
19
+ ```js
20
+ // pw-dashboard.config.js
21
+ module.exports = {
22
+ projectName: 'Acme E2E', // shown in topbar and footer
23
+ brandName: 'pw_dashboard', // top-left brand label
24
+ pageTitle: 'Acme Test Dashboard', // browser tab title
25
+ historyDir: 'tests/report/test-history', // must match playwright.config.ts
26
+ };
27
+ ```
28
+
29
+ A starter config file is included in the package at `pw-dashboard.config.js`.
30
+
31
+ ### 2. Generate the dashboard
32
+
33
+ ```bash
34
+ npx pw-history-init
35
+ ```
36
+
37
+ Reads your `pw-dashboard.config.js`, injects your settings, and writes `index.html` into `historyDir`. Re-run after upgrading the package to pick up dashboard updates; your config is always preserved.
38
+
39
+ ### 3. Register the reporter in `playwright.config.ts`
40
+
41
+ ```ts
42
+ import { defineConfig } from '@playwright/test';
43
+
44
+ export default defineConfig({
45
+ reporter: [
46
+ ['html'],
47
+ [
48
+ '@acahet/playwright-history-dashboard/reporter',
49
+ {
50
+ historyDir: 'tests/report/test-history', // match pw-dashboard.config.js
51
+ maxRuns: 30, // optional, default is 30
52
+ },
53
+ ],
54
+ ],
55
+ use: {
56
+ trace: 'on-first-retry',
57
+ screenshot: 'on', // required for the gallery page
58
+ },
59
+ });
60
+ ```
61
+
62
+ ### 4. Run tests and serve the dashboard
63
+
64
+ ```bash
65
+ npx playwright test
66
+ npx serve tests/report/test-history
67
+ ```
68
+
69
+ Open `http://localhost:3000` — the dashboard always shows the latest run.
70
+
71
+ ---
72
+
73
+ ## Features
74
+
75
+ ### Reporter
76
+
77
+ - Records every test run to `history-index.json`
78
+ - Captures pass, fail, flaky, skipped counts and total duration per run
79
+ - Stores per-test: title, file, project, duration, status, error message, tags, and Playwright annotations
80
+ - Detects flaky tests automatically — passed on retry after a prior failure
81
+ - Copies failure artifacts (trace + screenshot) into a per-run directory scoped to the specific failing test
82
+ - Retains the last **N runs** (default 30) as the single retention policy — index and disk stay in sync
83
+ - Orphan guard removes any run directories not referenced in the index
84
+ - Error boundary in `onEnd` — reporter failures never affect test exit codes
85
+ - Skips `setup` project tests
86
+ - Requires Playwright ≥ 1.42
87
+
88
+ ### Dashboard pages
89
+
90
+ **Dashboard**
91
+
92
+ - Suite health grade (A–F) on the latest run: 60% pass rate, 30% stability, 10% performance
93
+ - Latest run stat cards: pass rate, passed, failed, flaky, skipped, total, duration
94
+ - Clicking passed / failed / flaky / skipped filters that run's test list instantly
95
+ - Stacked bar chart across last 30 runs with hover tooltip
96
+ - Run duration line chart
97
+ - Per-test view: search by name, project, or tag; sparkline of last 10 runs per card
98
+
99
+ **Test detail** (click any test card)
100
+
101
+ - Full run history with date, runId, status, duration
102
+ - Duration-over-time mini chart with min / avg / max and `±% vs prev` delta
103
+ - Failure reason grouping — normalises error messages to surface recurring patterns
104
+ - Annotation support: `title` shown before the error, `description` in the header
105
+ - Playwright error collapsed by default, expandable on click
106
+
107
+ **Trends**
108
+
109
+ - 4 charts across last 30 runs: Pass rate, Duration, Flaky count, Slow count
110
+ - Each panel shows current value, delta vs previous run, and min / avg / max
111
+
112
+ **Gallery**
113
+
114
+ - Grid of failure screenshots grouped by run
115
+ - Lightbox on click, Escape to close
116
+
117
+ **Sidebar**
118
+
119
+ - Navigate: Dashboard, Trends, Search tests, Gallery
120
+ - Tag and Spec filter chips auto-populated from your test data
121
+ - Recent runs list — click any run to scroll and auto-expand it
122
+
123
+ **Run cards**
124
+
125
+ - Collapsed by default, showing failed + flaky only
126
+ - `SLOW` badge on tests above 1.5× the P75 duration of that run
127
+ - Errors collapsed inline, expandable per test
128
+ - Artifact links: download trace or screenshot per test
129
+
130
+ ---
131
+
132
+ ## Options
133
+
134
+ | Option | Type | Default | Description |
135
+ | ------------ | -------- | ------------------------------- | ------------------------------------------------- |
136
+ | `historyDir` | `string` | `'./tests/report/test-history'` | Where to write the JSON index and run directories |
137
+ | `maxRuns` | `number` | `30` | How many runs to keep in the index and on disk |
138
+
139
+ ---
140
+
141
+ ## Using annotations
142
+
143
+ ```ts
144
+ test('checkout fails with expired card', async ({ page }) => {
145
+ test.info().annotations.push(
146
+ { type: 'title', description: 'Known payment gateway timeout' },
147
+ {
148
+ type: 'description',
149
+ description: 'Card validation times out after 30s under load',
150
+ },
151
+ );
152
+ // test body
153
+ });
154
+ ```
155
+
156
+ The `title` annotation appears as a prominent label before the Playwright error in run history. The `description` appears in the test detail header. Any other annotation types appear as chips under the test name.
157
+
158
+ ---
159
+
160
+ ## Using with Azure App Testing
161
+
162
+ Create a thin wrapper config — your reporter and test code stay untouched:
163
+
164
+ ```ts
165
+ // playwright.service.config.ts
166
+ import { defineConfig } from '@playwright/test';
167
+ import { getServiceConfig } from '@azure/microsoft-playwright-testing';
168
+ import baseConfig from './playwright.config';
169
+
170
+ export default defineConfig(baseConfig, getServiceConfig(baseConfig), {
171
+ reporter: [
172
+ ['list'],
173
+ ['@azure/microsoft-playwright-testing/reporter'],
174
+ ['@acahet/playwright-history-dashboard'],
175
+ ],
176
+ });
177
+ ```
178
+
179
+ Run with Azure: `npx playwright test --config=playwright.service.config.ts`
180
+
181
+ To detach: delete the service config, remove the package. Zero changes to tests.
182
+
183
+ ---
184
+
185
+ ## File structure after setup
186
+
187
+ ```
188
+ your-project/
189
+ └── tests/
190
+ └── report/
191
+ └── test-history/
192
+ ├── index.html ← dashboard (copied by pw-history-init)
193
+ ├── history-index.json ← auto-generated after each run
194
+ └── runs/
195
+ └── <run-id>/
196
+ ├── <test>-trace.zip
197
+ └── <test>-screenshot.png
198
+ ```
199
+
200
+ Add to `.gitignore`:
201
+
202
+ ```
203
+ tests/report/test-history/runs/
204
+ tests/report/test-history/history-index.json
205
+ ```
206
+
207
+ ---
208
+
209
+ ## Requirements
210
+
211
+ - Playwright ≥ 1.42
212
+ - Node.js ≥ 18
213
+
214
+ ## License
215
+
216
+ MIT