testeiya 0.10.1 → 0.10.2

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 (225) hide show
  1. package/README.md +7 -19
  2. package/dist/prompt/clis.d.ts +7 -0
  3. package/dist/prompt/pipeline-report.d.ts +1 -0
  4. package/dist/prompt/report.d.ts +10 -0
  5. package/dist/prompt/system-prompt.d.ts +22 -0
  6. package/dist/prompt/testomat.io.d.ts +19 -0
  7. package/dist/prompt/thread.d.ts +73 -0
  8. package/dist/src/args.d.ts +39 -0
  9. package/dist/src/attribution-extension.d.ts +3 -0
  10. package/dist/src/checkpoint.d.ts +30 -0
  11. package/dist/src/cli.d.ts +2 -0
  12. package/dist/src/cli.js +27 -32
  13. package/dist/src/cli.js.map +1 -1
  14. package/dist/src/doctor.d.ts +11 -0
  15. package/dist/src/env.d.ts +30 -0
  16. package/dist/src/exec.d.ts +11 -0
  17. package/dist/src/git.d.ts +41 -0
  18. package/dist/src/langfuse-extension.d.ts +7 -0
  19. package/dist/src/langfuse.d.ts +67 -0
  20. package/dist/src/mcp.d.ts +19 -0
  21. package/dist/src/model.d.ts +20 -0
  22. package/dist/src/models.d.ts +1 -0
  23. package/dist/src/output.d.ts +84 -0
  24. package/dist/src/pipeline/command-stage.d.ts +12 -0
  25. package/dist/src/pipeline/crash-guard.d.ts +12 -0
  26. package/dist/src/pipeline/crash-guard.js +21 -0
  27. package/dist/src/pipeline/crash-guard.js.map +1 -0
  28. package/dist/src/pipeline/diagram.d.ts +24 -0
  29. package/dist/src/pipeline/gate.d.ts +21 -0
  30. package/dist/src/pipeline/launcher.d.ts +33 -0
  31. package/dist/src/pipeline/launcher.js +16 -3
  32. package/dist/src/pipeline/launcher.js.map +1 -1
  33. package/dist/src/pipeline/log.d.ts +29 -0
  34. package/dist/src/pipeline/log.js +9 -0
  35. package/dist/src/pipeline/log.js.map +1 -1
  36. package/dist/src/pipeline/overlay.d.ts +29 -0
  37. package/dist/src/pipeline/pipeline-file.d.ts +44 -0
  38. package/dist/src/pipeline/pipeline.d.ts +78 -0
  39. package/dist/src/pipeline/pipeline.js +22 -0
  40. package/dist/src/pipeline/pipeline.js.map +1 -1
  41. package/dist/src/pipeline/report.d.ts +26 -0
  42. package/dist/src/pipeline/report.js +13 -0
  43. package/dist/src/pipeline/report.js.map +1 -1
  44. package/dist/src/pipeline/spec.d.ts +63 -0
  45. package/dist/src/pipeline/stage-env.d.ts +13 -0
  46. package/dist/src/pipeline/stage-env.js +31 -0
  47. package/dist/src/pipeline/stage-env.js.map +1 -0
  48. package/dist/src/pipeline/stage.d.ts +71 -0
  49. package/dist/src/pipeline/stage.js.map +1 -1
  50. package/dist/src/pipeline/state.d.ts +63 -0
  51. package/dist/src/pipeline/summary-stage.d.ts +24 -0
  52. package/dist/src/pipeline/task-stage.d.ts +24 -0
  53. package/dist/src/pipeline/task-stage.js +86 -2
  54. package/dist/src/pipeline/task-stage.js.map +1 -1
  55. package/dist/src/pipeline/variables.d.ts +20 -0
  56. package/dist/src/result.d.ts +6 -0
  57. package/dist/src/run.d.ts +69 -0
  58. package/dist/src/run.js +116 -60
  59. package/dist/src/run.js.map +1 -1
  60. package/dist/src/session.d.ts +43 -0
  61. package/dist/src/sessions.d.ts +23 -0
  62. package/dist/src/skills.d.ts +29 -0
  63. package/package.json +11 -2
  64. package/pipelines/api-testing.yml +1 -1
  65. package/scripts/vendor-skills.js +62 -0
  66. package/skills/codeceptjs/ci-fix-tests/SKILL.md +0 -119
  67. package/skills/codeceptjs/codeceptjs-auth/SKILL.md +0 -141
  68. package/skills/codeceptjs/codeceptjs-exploration/SKILL.md +0 -100
  69. package/skills/codeceptjs/codeceptjs-fundamentals/SKILL.md +0 -196
  70. package/skills/codeceptjs/codeceptjs-run-analysis/SKILL.md +0 -83
  71. package/skills/codeceptjs/debugging-codeceptjs-tests/SKILL.md +0 -126
  72. package/skills/codeceptjs/lint-codeceptjs-tests/SKILL.md +0 -104
  73. package/skills/codeceptjs/migrate-codeceptjs-4/SKILL.md +0 -109
  74. package/skills/codeceptjs/migrate-cypress-to-codeceptjs/SKILL.md +0 -295
  75. package/skills/codeceptjs/migrate-protractor-to-codeceptjs/SKILL.md +0 -339
  76. package/skills/codeceptjs/migrate-selenium-java-to-codeceptjs/SKILL.md +0 -459
  77. package/skills/codeceptjs/migrate-testcafe-to-codeceptjs/SKILL.md +0 -338
  78. package/skills/codeceptjs/refactoring-codeceptjs-tests/SKILL.md +0 -78
  79. package/skills/codeceptjs/writing-codeceptjs-tests/SKILL.md +0 -102
  80. package/skills/playwright/playwright-best-practices/SKILL.md +0 -303
  81. package/skills/playwright/playwright-best-practices/advanced/authentication-flows.md +0 -360
  82. package/skills/playwright/playwright-best-practices/advanced/authentication.md +0 -871
  83. package/skills/playwright/playwright-best-practices/advanced/clock-mocking.md +0 -364
  84. package/skills/playwright/playwright-best-practices/advanced/mobile-testing.md +0 -409
  85. package/skills/playwright/playwright-best-practices/advanced/multi-context.md +0 -288
  86. package/skills/playwright/playwright-best-practices/advanced/multi-user.md +0 -393
  87. package/skills/playwright/playwright-best-practices/advanced/network-advanced.md +0 -452
  88. package/skills/playwright/playwright-best-practices/advanced/third-party.md +0 -464
  89. package/skills/playwright/playwright-best-practices/architecture/pom-vs-fixtures.md +0 -363
  90. package/skills/playwright/playwright-best-practices/architecture/test-architecture.md +0 -369
  91. package/skills/playwright/playwright-best-practices/architecture/when-to-mock.md +0 -383
  92. package/skills/playwright/playwright-best-practices/browser-apis/browser-apis.md +0 -391
  93. package/skills/playwright/playwright-best-practices/browser-apis/iframes.md +0 -403
  94. package/skills/playwright/playwright-best-practices/browser-apis/service-workers.md +0 -504
  95. package/skills/playwright/playwright-best-practices/browser-apis/websockets.md +0 -403
  96. package/skills/playwright/playwright-best-practices/core/annotations.md +0 -424
  97. package/skills/playwright/playwright-best-practices/core/assertions-waiting.md +0 -361
  98. package/skills/playwright/playwright-best-practices/core/configuration.md +0 -452
  99. package/skills/playwright/playwright-best-practices/core/fixtures-hooks.md +0 -417
  100. package/skills/playwright/playwright-best-practices/core/global-setup.md +0 -434
  101. package/skills/playwright/playwright-best-practices/core/locators.md +0 -242
  102. package/skills/playwright/playwright-best-practices/core/page-object-model.md +0 -315
  103. package/skills/playwright/playwright-best-practices/core/projects-dependencies.md +0 -453
  104. package/skills/playwright/playwright-best-practices/core/test-data.md +0 -492
  105. package/skills/playwright/playwright-best-practices/core/test-suite-structure.md +0 -361
  106. package/skills/playwright/playwright-best-practices/core/test-tags.md +0 -298
  107. package/skills/playwright/playwright-best-practices/debugging/console-errors.md +0 -420
  108. package/skills/playwright/playwright-best-practices/debugging/debugging.md +0 -504
  109. package/skills/playwright/playwright-best-practices/debugging/error-testing.md +0 -360
  110. package/skills/playwright/playwright-best-practices/debugging/flaky-tests.md +0 -496
  111. package/skills/playwright/playwright-best-practices/frameworks/angular.md +0 -530
  112. package/skills/playwright/playwright-best-practices/frameworks/nextjs.md +0 -469
  113. package/skills/playwright/playwright-best-practices/frameworks/react.md +0 -531
  114. package/skills/playwright/playwright-best-practices/frameworks/vue.md +0 -574
  115. package/skills/playwright/playwright-best-practices/infrastructure-ci-cd/ci-cd.md +0 -468
  116. package/skills/playwright/playwright-best-practices/infrastructure-ci-cd/docker.md +0 -283
  117. package/skills/playwright/playwright-best-practices/infrastructure-ci-cd/github-actions.md +0 -546
  118. package/skills/playwright/playwright-best-practices/infrastructure-ci-cd/gitlab.md +0 -397
  119. package/skills/playwright/playwright-best-practices/infrastructure-ci-cd/other-providers.md +0 -521
  120. package/skills/playwright/playwright-best-practices/infrastructure-ci-cd/parallel-sharding.md +0 -371
  121. package/skills/playwright/playwright-best-practices/infrastructure-ci-cd/performance.md +0 -453
  122. package/skills/playwright/playwright-best-practices/infrastructure-ci-cd/reporting.md +0 -424
  123. package/skills/playwright/playwright-best-practices/infrastructure-ci-cd/test-coverage.md +0 -497
  124. package/skills/playwright/playwright-best-practices/testing-patterns/accessibility.md +0 -359
  125. package/skills/playwright/playwright-best-practices/testing-patterns/api-testing.md +0 -719
  126. package/skills/playwright/playwright-best-practices/testing-patterns/browser-extensions.md +0 -506
  127. package/skills/playwright/playwright-best-practices/testing-patterns/canvas-webgl.md +0 -493
  128. package/skills/playwright/playwright-best-practices/testing-patterns/component-testing.md +0 -500
  129. package/skills/playwright/playwright-best-practices/testing-patterns/drag-drop.md +0 -576
  130. package/skills/playwright/playwright-best-practices/testing-patterns/electron.md +0 -509
  131. package/skills/playwright/playwright-best-practices/testing-patterns/file-operations.md +0 -377
  132. package/skills/playwright/playwright-best-practices/testing-patterns/file-upload-download.md +0 -562
  133. package/skills/playwright/playwright-best-practices/testing-patterns/forms-validation.md +0 -561
  134. package/skills/playwright/playwright-best-practices/testing-patterns/graphql-testing.md +0 -331
  135. package/skills/playwright/playwright-best-practices/testing-patterns/i18n.md +0 -508
  136. package/skills/playwright/playwright-best-practices/testing-patterns/performance-testing.md +0 -476
  137. package/skills/playwright/playwright-best-practices/testing-patterns/security-testing.md +0 -430
  138. package/skills/playwright/playwright-best-practices/testing-patterns/visual-regression.md +0 -634
  139. package/skills/playwright/playwright-cli/SKILL.md +0 -489
  140. package/skills/playwright/playwright-cli/references/element-attributes.md +0 -23
  141. package/skills/playwright/playwright-cli/references/playwright-tests.md +0 -39
  142. package/skills/playwright/playwright-cli/references/pr-attachments.md +0 -60
  143. package/skills/playwright/playwright-cli/references/request-mocking.md +0 -87
  144. package/skills/playwright/playwright-cli/references/running-code.md +0 -245
  145. package/skills/playwright/playwright-cli/references/session-management.md +0 -227
  146. package/skills/playwright/playwright-cli/references/storage-state.md +0 -275
  147. package/skills/playwright/playwright-cli/references/test-generation.md +0 -433
  148. package/skills/playwright/playwright-cli/references/tracing.md +0 -139
  149. package/skills/playwright/playwright-cli/references/video-recording.md +0 -216
  150. package/skills/skills.lock.json +0 -89
  151. package/skills/skills.yaml +0 -35
  152. /package/skills/{testomatio/explorbot → explorbot}/explorbot-fundamentals/SKILL.md +0 -0
  153. /package/skills/{testomatio/explorbot → explorbot}/explorbot-fundamentals/references/no-install.md +0 -0
  154. /package/skills/{testomatio/explorbot → explorbot}/explorbot-plan/SKILL.md +0 -0
  155. /package/skills/{testomatio/explorbot → explorbot}/explorbot-setup/SKILL.md +0 -0
  156. /package/skills/{testomatio/explorbot → explorbot}/prima/SKILL.md +0 -0
  157. /package/skills/{testomatio/qa-process → qa-process}/qa-lead-strategy-advisor/SKILL.md +0 -0
  158. /package/skills/{testomatio/qa-process → qa-process}/qa-lead-strategy-advisor/references/output-format.md +0 -0
  159. /package/skills/{testomatio/qa-process → qa-process}/qa-review-pr/SKILL.md +0 -0
  160. /package/skills/{testomatio/qa-process → qa-process}/testing-workflow/SKILL.md +0 -0
  161. /package/skills/{testomatio/requirements → requirements}/catalog-features/SKILL.md +0 -0
  162. /package/skills/{testomatio/requirements → requirements}/catalog-features/references/layout.md +0 -0
  163. /package/skills/{testomatio/requirements → requirements}/detect-product-mismatches/SKILL.md +0 -0
  164. /package/skills/{testomatio/requirements → requirements}/detect-product-mismatches/references/features.md +0 -0
  165. /package/skills/{testomatio/requirements → requirements}/detect-product-mismatches/references/layout.md +0 -0
  166. /package/skills/{testomatio/requirements → requirements}/pull-request-diff-analyzer/SKILL.md +0 -0
  167. /package/skills/{testomatio/requirements → requirements}/qa-explain-behavior/SKILL.md +0 -0
  168. /package/skills/{testomatio/requirements → requirements}/qa-explain-behavior/references/answer-shapes.md +0 -0
  169. /package/skills/{testomatio/requirements → requirements}/qa-explain-behavior/references/examples.md +0 -0
  170. /package/skills/{testomatio/requirements → requirements}/qa-pr-requirements-analyzer/SKILL.md +0 -0
  171. /package/skills/{testomatio/requirements → requirements}/qa-pr-requirements-analyzer/references/summary-example.md +0 -0
  172. /package/skills/{testomatio/requirements → requirements}/qa-requirement-reviewer/SKILL.md +0 -0
  173. /package/skills/{testomatio/requirements → requirements}/qa-requirement-reviewer/references/requirements_reviewer_examples.md +0 -0
  174. /package/skills/{testomatio/requirements → requirements}/qa-thinking/SKILL.md +0 -0
  175. /package/skills/{testomatio/requirements → requirements}/wiki-from-code/SKILL.md +0 -0
  176. /package/skills/{testomatio/requirements → requirements}/wiki-from-code/references/behaviors.md +0 -0
  177. /package/skills/{testomatio/requirements → requirements}/wiki-from-code/references/layout.md +0 -0
  178. /package/skills/{testomatio/requirements → requirements}/write-user-story/SKILL.md +0 -0
  179. /package/skills/{testomatio/test-automation → test-automation}/automate-manual-test-cases/CLAUDE.md +0 -0
  180. /package/skills/{testomatio/test-automation → test-automation}/automate-manual-test-cases/SKILL.md +0 -0
  181. /package/skills/{testomatio/test-automation → test-automation}/automate-manual-test-cases/references/CODECEPTJS_BEST_PRACTICES.md +0 -0
  182. /package/skills/{testomatio/test-automation → test-automation}/automate-manual-test-cases/references/FINAL_SUMMARY_TEMPLATE.md +0 -0
  183. /package/skills/{testomatio/test-automation → test-automation}/automate-manual-test-cases/references/PLAYWRIGHT_BEST_PRACTICES.md +0 -0
  184. /package/skills/{testomatio/test-automation → test-automation}/automate-manual-test-cases/references/POM_BEST_PRACTICES.md +0 -0
  185. /package/skills/{testomatio/test-automation → test-automation}/automate-manual-test-cases/references/TEST_DATA_MANAGEMENT.md +0 -0
  186. /package/skills/{testomatio/test-automation → test-automation}/debug-fix-failed-flaky-autotests/SKILL.md +0 -0
  187. /package/skills/{testomatio/test-automation → test-automation}/debug-fix-failed-flaky-autotests/references/DEBUGGING_QUICK_REFERENCE.md +0 -0
  188. /package/skills/{testomatio/test-automation → test-automation}/epic-requirements-specification/SKILL.md +0 -0
  189. /package/skills/{testomatio/test-automation → test-automation}/qa-automation-test-consolidation/SKILL.md +0 -0
  190. /package/skills/{testomatio/test-automation → test-automation}/qa-data-seeder/SKILL.md +0 -0
  191. /package/skills/{testomatio/test-automation → test-automation}/run-tests-with-testomatio-reporter/SKILL.md +0 -0
  192. /package/skills/{testomatio/test-automation → test-automation}/setup-change-aware-pr-testing/SKILL.md +0 -0
  193. /package/skills/{testomatio/test-automation → test-automation}/setup-ci-automation/SKILL.md +0 -0
  194. /package/skills/{testomatio/test-automation → test-automation}/testomat-allure-adapter/SKILL.md +0 -0
  195. /package/skills/{testomatio/test-management → test-management}/detect-duplicate-test-cases/SKILL.md +0 -0
  196. /package/skills/{testomatio/test-management → test-management}/detect-duplicate-test-cases/references/DUPLICATE_INSTRUCTIONS.md +0 -0
  197. /package/skills/{testomatio/test-management → test-management}/detect-useless-tests/SKILL.md +0 -0
  198. /package/skills/{testomatio/test-management → test-management}/improve-test-cases/SKILL.md +0 -0
  199. /package/skills/{testomatio/test-management → test-management}/improve-test-cases/references/TESTOMAT_MARKDOWN_EXAMPLE.md +0 -0
  200. /package/skills/{testomatio/test-management → test-management}/migrate-to-testomatio/SKILL.md +0 -0
  201. /package/skills/{testomatio/test-management → test-management}/migrate-to-testomatio/references/CSV_MIGRATION.md +0 -0
  202. /package/skills/{testomatio/test-management → test-management}/migrate-to-testomatio/references/CUSTOM_MIGRATION.md +0 -0
  203. /package/skills/{testomatio/test-management → test-management}/migrate-to-testomatio/references/TESTMO_MIGRATION.md +0 -0
  204. /package/skills/{testomatio/test-management → test-management}/migrate-to-testomatio/references/TESTRAIL_MIGRATION.md +0 -0
  205. /package/skills/{testomatio/test-management → test-management}/migrate-to-testomatio/references/XRAY_MIGRATION.md +0 -0
  206. /package/skills/{testomatio/test-management → test-management}/qa-e2e-tests-reporting/SKILL.md +0 -0
  207. /package/skills/{testomatio/test-management → test-management}/qa-e2e-tests-reporting/references/TESTOMATIO_ARTIFACTS.md +0 -0
  208. /package/skills/{testomatio/test-management → test-management}/qa-e2e-tests-reporting/references/TESTOMATIO_HTML_REPORT.md +0 -0
  209. /package/skills/{testomatio/test-management → test-management}/qa-e2e-tests-reporting/references/TESTOMATIO_REPORTERS_CONFIG.md +0 -0
  210. /package/skills/{testomatio/test-management → test-management}/qa-split-testing-levels-pyramid/SKILL.md +0 -0
  211. /package/skills/{testomatio/test-management → test-management}/qa-sprint-report-by-testomatio/SKILL.md +0 -0
  212. /package/skills/{testomatio/test-management → test-management}/qa-sprint-report-by-testomatio/references/qa-sprint-report.md +0 -0
  213. /package/skills/{testomatio/test-management → test-management}/qa-test-code-coverage/SKILL.md +0 -0
  214. /package/skills/{testomatio/test-management → test-management}/qa-test-code-coverage/references/COVERAGE_FILE_FORMAT.md +0 -0
  215. /package/skills/{testomatio/test-management → test-management}/qa-test-code-coverage/references/E2E_FRAMEWORKS.md +0 -0
  216. /package/skills/{testomatio/test-management → test-management}/qa-test-code-coverage/scripts/check-coverage.mjs +0 -0
  217. /package/skills/{testomatio/test-management → test-management}/qa-write-test-cases/SKILL.md +0 -0
  218. /package/skills/{testomatio/test-management → test-management}/qa-write-test-cases/references/test-case-format.md +0 -0
  219. /package/skills/{testomatio/test-management → test-management}/qa-write-test-cases/references/testomat-tms-guide.md +0 -0
  220. /package/skills/{testomatio/test-management → test-management}/qa-write-test-cases/references/writing-rule.md +0 -0
  221. /package/skills/{testomatio/test-management → test-management}/scan-automation-project/SKILL.md +0 -0
  222. /package/skills/{testomatio/test-management → test-management}/sync-test-cases-with-tms/SKILL.md +0 -0
  223. /package/skills/{testomatio/test-management → test-management}/sync-test-cases-with-tms/references/TESTOMATIO_CLI.md +0 -0
  224. /package/skills/{testomatio/test-management → test-management}/testomatio-mcp/SKILL.md +0 -0
  225. /package/skills/{testomatio/test-management → test-management}/testomatio-mcp/references/MCP_SETUP.md +0 -0
@@ -1,497 +0,0 @@
1
- # Test Coverage
2
-
3
- ## Table of Contents
4
-
5
- 1. [Coverage Setup](#coverage-setup)
6
- 2. [Collecting Coverage](#collecting-coverage)
7
- 3. [Coverage Reports](#coverage-reports)
8
- 4. [Coverage Thresholds](#coverage-thresholds)
9
- 5. [Advanced Patterns](#advanced-patterns)
10
- 6. [CI Integration](#ci-integration)
11
-
12
- ## Coverage Setup
13
-
14
- ### Install Dependencies
15
-
16
- ```bash
17
- # For V8 coverage (built into Playwright)
18
- # No additional dependencies needed
19
-
20
- # For Istanbul-based coverage (more features)
21
- npm install -D nyc @istanbuljs/nyc-config-typescript
22
- ```
23
-
24
- ### Basic Configuration
25
-
26
- ```typescript
27
- // playwright.config.ts
28
- import { defineConfig } from "@playwright/test";
29
-
30
- export default defineConfig({
31
- use: {
32
- // Enable coverage collection
33
- contextOptions: {
34
- // V8 coverage is automatic with the API below
35
- },
36
- },
37
- });
38
- ```
39
-
40
- ### V8 Coverage Fixture
41
-
42
- ```typescript
43
- // fixtures/coverage.ts
44
- import { test as base, expect } from "@playwright/test";
45
- import fs from "fs";
46
- import path from "path";
47
- import { randomUUID } from "crypto";
48
-
49
- export const test = base.extend<{}, { collectCoverage: void }>({
50
- collectCoverage: [
51
- async ({ browser }, use) => {
52
- // Start coverage for all pages
53
- const context = await browser.newContext();
54
- const page = await context.newPage();
55
-
56
- await page.coverage.startJSCoverage();
57
- await page.coverage.startCSSCoverage();
58
-
59
- await use();
60
-
61
- // Collect coverage
62
- const [jsCoverage, cssCoverage] = await Promise.all([
63
- page.coverage.stopJSCoverage(),
64
- page.coverage.stopCSSCoverage(),
65
- ]);
66
-
67
- // Save coverage data
68
- const coverageDir = "./coverage";
69
- if (!fs.existsSync(coverageDir)) {
70
- fs.mkdirSync(coverageDir, { recursive: true });
71
- }
72
-
73
- fs.writeFileSync(
74
- path.join(coverageDir, `coverage-${randomUUID()}.json`),
75
- JSON.stringify([...jsCoverage, ...cssCoverage])
76
- );
77
-
78
- await context.close();
79
- },
80
- { scope: "worker", auto: true },
81
- ],
82
- });
83
- ```
84
-
85
- ## Collecting Coverage
86
-
87
- ### Per-Test Coverage
88
-
89
- ```typescript
90
- test("collect coverage for single test", async ({ page }) => {
91
- // Start coverage collection
92
- await page.coverage.startJSCoverage({
93
- resetOnNavigation: false,
94
- });
95
-
96
- // Run test
97
- await page.goto("/app");
98
- await page.getByRole("button", { name: "Submit" }).click();
99
- await expect(page.getByText("Success")).toBeVisible();
100
-
101
- // Stop and get coverage
102
- const coverage = await page.coverage.stopJSCoverage();
103
-
104
- // Filter to only your source files
105
- const appCoverage = coverage.filter((entry) => entry.url.includes("/src/"));
106
-
107
- console.log(`Covered ${appCoverage.length} source files`);
108
- });
109
- ```
110
-
111
- ### Coverage for Specific Files
112
-
113
- ```typescript
114
- test("track specific module coverage", async ({ page }) => {
115
- await page.coverage.startJSCoverage();
116
-
117
- await page.goto("/checkout");
118
- await page.getByRole("button", { name: "Pay" }).click();
119
-
120
- const coverage = await page.coverage.stopJSCoverage();
121
-
122
- // Find coverage for checkout module
123
- const checkoutCoverage = coverage.find((c) => c.url.includes("checkout.js"));
124
-
125
- if (checkoutCoverage) {
126
- const totalBytes = checkoutCoverage.text?.length || 0;
127
- const coveredBytes = checkoutCoverage.ranges.reduce(
128
- (sum, range) => sum + (range.end - range.start),
129
- 0
130
- );
131
- const percentage = (coveredBytes / totalBytes) * 100;
132
-
133
- console.log(`Checkout module: ${percentage.toFixed(1)}% covered`);
134
- expect(percentage).toBeGreaterThan(80);
135
- }
136
- });
137
- ```
138
-
139
- ### CSS Coverage
140
-
141
- ```typescript
142
- test("collect CSS coverage", async ({ page }) => {
143
- await page.coverage.startCSSCoverage();
144
-
145
- await page.goto("/app");
146
-
147
- // Interact to trigger different CSS states
148
- await page.getByRole("button").hover();
149
- await page.getByRole("dialog").waitFor();
150
-
151
- const cssCoverage = await page.coverage.stopCSSCoverage();
152
-
153
- // Find unused CSS
154
- for (const entry of cssCoverage) {
155
- const totalBytes = entry.text?.length || 0;
156
- const usedBytes = entry.ranges.reduce(
157
- (sum, range) => sum + (range.end - range.start),
158
- 0
159
- );
160
- const unusedPercentage = ((totalBytes - usedBytes) / totalBytes) * 100;
161
-
162
- if (unusedPercentage > 50) {
163
- console.warn(`${entry.url}: ${unusedPercentage.toFixed(1)}% unused CSS`);
164
- }
165
- }
166
- });
167
- ```
168
-
169
- ## Coverage Reports
170
-
171
- ### Converting to Istanbul Format
172
-
173
- ```typescript
174
- // scripts/convert-coverage.ts
175
- import { execSync } from "child_process";
176
- import fs from "fs";
177
- import path from "path";
178
- import v8ToIstanbul from "v8-to-istanbul";
179
-
180
- async function convertCoverage() {
181
- const coverageDir = "./coverage";
182
- const files = fs.readdirSync(coverageDir).filter((f) => f.endsWith(".json"));
183
-
184
- const istanbulCoverage: any = {};
185
-
186
- for (const file of files) {
187
- const coverageData = JSON.parse(
188
- fs.readFileSync(path.join(coverageDir, file), "utf-8")
189
- );
190
-
191
- for (const entry of coverageData) {
192
- if (!entry.url.startsWith("file://")) continue;
193
-
194
- const filePath = entry.url.replace("file://", "");
195
- const converter = v8ToIstanbul(filePath);
196
-
197
- await converter.load();
198
- converter.applyCoverage(entry.functions || []);
199
-
200
- const istanbul = converter.toIstanbul();
201
- Object.assign(istanbulCoverage, istanbul);
202
- }
203
- }
204
-
205
- fs.writeFileSync(
206
- path.join(coverageDir, "coverage-final.json"),
207
- JSON.stringify(istanbulCoverage)
208
- );
209
- }
210
-
211
- convertCoverage();
212
- ```
213
-
214
- ### Generating HTML Report
215
-
216
- ```bash
217
- # Using nyc to generate report
218
- npx nyc report --reporter=html --reporter=text --temp-dir=./coverage
219
- ```
220
-
221
- ```typescript
222
- // package.json scripts
223
- {
224
- "scripts": {
225
- "test": "playwright test",
226
- "test:coverage": "playwright test && npm run coverage:report",
227
- "coverage:report": "npx nyc report --reporter=html --reporter=lcov --temp-dir=./coverage"
228
- }
229
- }
230
- ```
231
-
232
- ### Custom Coverage Reporter
233
-
234
- ```typescript
235
- // reporters/coverage-reporter.ts
236
- import type { Reporter, FullResult } from "@playwright/test/reporter";
237
- import fs from "fs";
238
- import path from "path";
239
-
240
- class CoverageReporter implements Reporter {
241
- private coverageData: any[] = [];
242
-
243
- onEnd(result: FullResult) {
244
- // Aggregate all coverage files
245
- const coverageDir = "./coverage";
246
- const files = fs
247
- .readdirSync(coverageDir)
248
- .filter((f) => f.endsWith(".json"));
249
-
250
- for (const file of files) {
251
- const data = JSON.parse(
252
- fs.readFileSync(path.join(coverageDir, file), "utf-8")
253
- );
254
- this.coverageData.push(...data);
255
- }
256
-
257
- // Generate summary
258
- const summary = this.generateSummary();
259
- console.log("\n📊 Coverage Summary:");
260
- console.log(` Files: ${summary.totalFiles}`);
261
- console.log(` Lines: ${summary.lineCoverage.toFixed(1)}%`);
262
- console.log(` Bytes: ${summary.byteCoverage.toFixed(1)}%`);
263
-
264
- if (summary.lineCoverage < 80) {
265
- console.warn("⚠️ Coverage below 80% threshold!");
266
- }
267
- }
268
-
269
- private generateSummary() {
270
- let totalBytes = 0;
271
- let coveredBytes = 0;
272
- const files = new Set<string>();
273
-
274
- for (const entry of this.coverageData) {
275
- if (entry.url.includes("/src/")) {
276
- files.add(entry.url);
277
- totalBytes += entry.text?.length || 0;
278
- coveredBytes += entry.ranges.reduce(
279
- (sum: number, r: any) => sum + (r.end - r.start),
280
- 0
281
- );
282
- }
283
- }
284
-
285
- return {
286
- totalFiles: files.size,
287
- byteCoverage: (coveredBytes / totalBytes) * 100,
288
- lineCoverage: (coveredBytes / totalBytes) * 100, // Simplified
289
- };
290
- }
291
- }
292
-
293
- export default CoverageReporter;
294
- ```
295
-
296
- ## Coverage Thresholds
297
-
298
- ### Enforcing Minimum Coverage
299
-
300
- ```typescript
301
- // tests/coverage.spec.ts
302
- import { test, expect } from "@playwright/test";
303
- import fs from "fs";
304
- import path from "path";
305
-
306
- test.afterAll(async () => {
307
- const coverageDir = "./coverage";
308
- const files = fs.readdirSync(coverageDir).filter((f) => f.endsWith(".json"));
309
-
310
- let totalBytes = 0;
311
- let coveredBytes = 0;
312
-
313
- for (const file of files) {
314
- const coverage = JSON.parse(
315
- fs.readFileSync(path.join(coverageDir, file), "utf-8")
316
- );
317
-
318
- for (const entry of coverage) {
319
- if (!entry.url.includes("/src/")) continue;
320
- totalBytes += entry.text?.length || 0;
321
- coveredBytes += entry.ranges.reduce(
322
- (sum: number, r: any) => sum + (r.end - r.start),
323
- 0
324
- );
325
- }
326
- }
327
-
328
- const coveragePercent = (coveredBytes / totalBytes) * 100;
329
-
330
- // Enforce threshold
331
- expect(coveragePercent).toBeGreaterThan(80);
332
- });
333
- ```
334
-
335
- ### Per-Directory Thresholds
336
-
337
- ```typescript
338
- // coverage-check.ts
339
- interface CoverageThreshold {
340
- pattern: RegExp;
341
- minCoverage: number;
342
- }
343
-
344
- const thresholds: CoverageThreshold[] = [
345
- { pattern: /\/src\/core\//, minCoverage: 90 },
346
- { pattern: /\/src\/utils\//, minCoverage: 85 },
347
- { pattern: /\/src\/components\//, minCoverage: 70 },
348
- { pattern: /\/src\/pages\//, minCoverage: 60 },
349
- ];
350
-
351
- function checkThresholds(coverage: any[]): string[] {
352
- const violations: string[] = [];
353
-
354
- for (const threshold of thresholds) {
355
- const matchingFiles = coverage.filter((c) => threshold.pattern.test(c.url));
356
-
357
- let total = 0;
358
- let covered = 0;
359
-
360
- for (const file of matchingFiles) {
361
- total += file.text?.length || 0;
362
- covered += file.ranges.reduce(
363
- (sum: number, r: any) => sum + (r.end - r.start),
364
- 0
365
- );
366
- }
367
-
368
- const percent = total > 0 ? (covered / total) * 100 : 0;
369
-
370
- if (percent < threshold.minCoverage) {
371
- violations.push(
372
- `${threshold.pattern}: ${percent.toFixed(1)}% < ${
373
- threshold.minCoverage
374
- }%`
375
- );
376
- }
377
- }
378
-
379
- return violations;
380
- }
381
- ```
382
-
383
- ## Advanced Patterns
384
-
385
- ### Merging Coverage Across Shards
386
-
387
- ```typescript
388
- // scripts/merge-coverage.ts
389
- import fs from "fs";
390
- import { glob } from "glob";
391
-
392
- async function mergeCoverage() {
393
- const files = await glob("shard-*/coverage/*.json");
394
- const merged = new Map<string, any>();
395
-
396
- for (const file of files) {
397
- const data = JSON.parse(fs.readFileSync(file, "utf-8"));
398
- for (const entry of data) {
399
- if (merged.has(entry.url)) {
400
- const existing = merged.get(entry.url);
401
- existing.ranges.push(...entry.ranges);
402
- } else {
403
- merged.set(entry.url, { ...entry });
404
- }
405
- }
406
- }
407
-
408
- fs.writeFileSync(
409
- "./coverage/merged.json",
410
- JSON.stringify([...merged.values()])
411
- );
412
- }
413
-
414
- mergeCoverage();
415
- ```
416
-
417
- ### Incremental Coverage
418
-
419
- ```typescript
420
- // Check coverage only for changed files in CI
421
- import { execSync } from "child_process";
422
- import fs from "fs";
423
-
424
- const changedFiles = execSync("git diff --name-only HEAD~1")
425
- .toString()
426
- .split("\n")
427
- .filter((f) => f.endsWith(".ts"));
428
-
429
- const coverage = JSON.parse(fs.readFileSync("./coverage/merged.json", "utf-8"));
430
-
431
- for (const file of changedFiles) {
432
- const entry = coverage.find((c: any) => c.url.includes(file));
433
- if (entry) {
434
- const percent =
435
- (entry.ranges.reduce((s: number, r: any) => s + r.end - r.start, 0) /
436
- (entry.text?.length || 1)) *
437
- 100;
438
- console.log(`${file}: ${percent.toFixed(1)}%`);
439
- }
440
- }
441
- ```
442
-
443
- ## CI Integration
444
-
445
- ### GitHub Actions
446
-
447
- ```yaml
448
- # .github/workflows/test.yml
449
- name: Tests with Coverage
450
-
451
- on: [push, pull_request]
452
-
453
- jobs:
454
- test:
455
- runs-on: ubuntu-latest
456
- steps:
457
- - uses: actions/checkout@v4
458
-
459
- - uses: actions/setup-node@v4
460
- with:
461
- node-version: 22
462
-
463
- - run: npm ci
464
- - run: npx playwright install --with-deps
465
-
466
- - name: Run tests with coverage
467
- run: npm run test:coverage
468
-
469
- - name: Upload coverage to Codecov
470
- uses: codecov/codecov-action@v3
471
- with:
472
- files: ./coverage/lcov.info
473
- fail_ci_if_error: true
474
-
475
- - name: Check coverage threshold
476
- run: |
477
- COVERAGE=$(cat coverage/coverage-summary.json | jq '.total.lines.pct')
478
- if (( $(echo "$COVERAGE < 80" | bc -l) )); then
479
- echo "Coverage $COVERAGE% is below 80% threshold"
480
- exit 1
481
- fi
482
- ```
483
-
484
- ## Anti-Patterns to Avoid
485
-
486
- | Anti-Pattern | Problem | Solution |
487
- | ---------------------------- | -------------------------------------- | --------------------------- |
488
- | Coverage for coverage's sake | Gaming metrics | Focus on critical paths |
489
- | 100% coverage target | Diminishing returns, tests for getters | Set realistic thresholds |
490
- | Ignoring coverage drops | Technical debt | Enforce thresholds in CI |
491
- | No source map support | Wrong line numbers | Enable source maps in build |
492
- | Coverage only in CI | Late feedback | Run locally too |
493
-
494
- ## Related References
495
-
496
- - **CI/CD**: See [ci-cd.md](ci-cd.md) for pipeline configuration
497
- - **Performance**: See [performance.md](performance.md) for optimizing coverage collection