qa-skills 3.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.
- package/README.md +168 -0
- package/bin/cli.js +42 -0
- package/dist/agents/registry.d.ts +5 -0
- package/dist/agents/registry.d.ts.map +1 -0
- package/dist/agents/registry.js +101 -0
- package/dist/agents/registry.js.map +1 -0
- package/dist/agents/types.d.ts +9 -0
- package/dist/agents/types.d.ts.map +1 -0
- package/dist/agents/types.js +2 -0
- package/dist/agents/types.js.map +1 -0
- package/dist/dependencies.d.ts +21 -0
- package/dist/dependencies.d.ts.map +1 -0
- package/dist/dependencies.js +125 -0
- package/dist/dependencies.js.map +1 -0
- package/dist/installer.d.ts +25 -0
- package/dist/installer.d.ts.map +1 -0
- package/dist/installer.js +437 -0
- package/dist/installer.js.map +1 -0
- package/dist/scaffold.d.ts +27 -0
- package/dist/scaffold.d.ts.map +1 -0
- package/dist/scaffold.js +182 -0
- package/dist/scaffold.js.map +1 -0
- package/package.json +40 -0
- package/skills/qa-accessibility-test-writer/SKILL.md +127 -0
- package/skills/qa-accessibility-test-writer/references/axe-core-patterns.md +349 -0
- package/skills/qa-accessibility-test-writer/references/best-practices.md +184 -0
- package/skills/qa-accessibility-test-writer/references/wcag-tests.md +331 -0
- package/skills/qa-api-contract-curator/SKILL.md +104 -0
- package/skills/qa-api-contract-curator/references/breaking-changes.md +363 -0
- package/skills/qa-api-contract-curator/references/openapi-structure.md +404 -0
- package/skills/qa-browser-data-collector/SKILL.md +132 -0
- package/skills/qa-browser-data-collector/references/data-collection-checklist.md +91 -0
- package/skills/qa-browser-data-collector/references/playwright-mcp-patterns.md +113 -0
- package/skills/qa-bug-ticket-creator/SKILL.md +148 -0
- package/skills/qa-bug-ticket-creator/references/bug-report-format.md +149 -0
- package/skills/qa-bug-ticket-creator/references/severity-guide.md +81 -0
- package/skills/qa-bug-ticket-creator/templates/bug-ticket-template.md +39 -0
- package/skills/qa-changelog-analyzer/SKILL.md +134 -0
- package/skills/qa-changelog-analyzer/references/git-analysis-patterns.md +138 -0
- package/skills/qa-changelog-analyzer/references/impact-mapping.md +120 -0
- package/skills/qa-clickup-integration/SKILL.md +166 -0
- package/skills/qa-clickup-integration/references/api-patterns.md +102 -0
- package/skills/qa-clickup-integration/references/field-mapping.md +71 -0
- package/skills/qa-codeceptjs-writer/SKILL.md +136 -0
- package/skills/qa-codeceptjs-writer/references/best-practices.md +207 -0
- package/skills/qa-codeceptjs-writer/references/config.md +255 -0
- package/skills/qa-codeceptjs-writer/references/patterns.md +285 -0
- package/skills/qa-coverage-analyzer/SKILL.md +166 -0
- package/skills/qa-coverage-analyzer/references/best-practices.md +142 -0
- package/skills/qa-coverage-analyzer/references/coverage-dimensions.md +155 -0
- package/skills/qa-coverage-analyzer/references/tools.md +204 -0
- package/skills/qa-cypress-writer/SKILL.md +134 -0
- package/skills/qa-cypress-writer/references/assertions.md +121 -0
- package/skills/qa-cypress-writer/references/best-practices.md +82 -0
- package/skills/qa-cypress-writer/references/config.md +121 -0
- package/skills/qa-cypress-writer/references/patterns.md +170 -0
- package/skills/qa-data-factory/SKILL.md +126 -0
- package/skills/qa-data-factory/references/factory-patterns.md +164 -0
- package/skills/qa-data-factory/references/faker-guide.md +131 -0
- package/skills/qa-diagram-generator/SKILL.md +125 -0
- package/skills/qa-diagram-generator/references/c4-model.md +53 -0
- package/skills/qa-diagram-generator/references/charts.md +58 -0
- package/skills/qa-diagram-generator/references/class-diagram.md +85 -0
- package/skills/qa-diagram-generator/references/er-diagram.md +69 -0
- package/skills/qa-diagram-generator/references/flowchart.md +92 -0
- package/skills/qa-diagram-generator/references/from-screenshot.md +45 -0
- package/skills/qa-diagram-generator/references/gantt.md +49 -0
- package/skills/qa-diagram-generator/references/journey.md +50 -0
- package/skills/qa-diagram-generator/references/mindmap.md +75 -0
- package/skills/qa-diagram-generator/references/sequence.md +69 -0
- package/skills/qa-diagram-generator/references/state-diagram.md +56 -0
- package/skills/qa-discovery-interview/SKILL.md +182 -0
- package/skills/qa-discovery-interview/references/completeness-checklist.md +53 -0
- package/skills/qa-discovery-interview/references/conflict-patterns.md +101 -0
- package/skills/qa-discovery-interview/references/qa-categories.md +147 -0
- package/skills/qa-discovery-interview/templates/qa-brief-template.md +168 -0
- package/skills/qa-environment-checker/SKILL.md +142 -0
- package/skills/qa-environment-checker/references/dependency-matrix.md +101 -0
- package/skills/qa-environment-checker/references/health-checks.md +209 -0
- package/skills/qa-environment-checker/templates/env-readiness-template.md +64 -0
- package/skills/qa-flaky-detector/SKILL.md +153 -0
- package/skills/qa-flaky-detector/references/ci-analysis.md +140 -0
- package/skills/qa-flaky-detector/references/flaky-patterns.md +247 -0
- package/skills/qa-github-issues-enhanced/SKILL.md +175 -0
- package/skills/qa-github-issues-enhanced/references/issue-templates.md +425 -0
- package/skills/qa-github-issues-enhanced/references/label-taxonomy.md +130 -0
- package/skills/qa-github-issues-enhanced/references/workflow-patterns.md +188 -0
- package/skills/qa-httpx-writer/SKILL.md +138 -0
- package/skills/qa-httpx-writer/references/assertions.md +195 -0
- package/skills/qa-httpx-writer/references/best-practices.md +140 -0
- package/skills/qa-httpx-writer/references/config.md +212 -0
- package/skills/qa-httpx-writer/references/patterns.md +262 -0
- package/skills/qa-jest-writer/SKILL.md +131 -0
- package/skills/qa-jest-writer/references/assertions.md +125 -0
- package/skills/qa-jest-writer/references/best-practices.md +136 -0
- package/skills/qa-jest-writer/references/config.md +134 -0
- package/skills/qa-jest-writer/references/patterns.md +172 -0
- package/skills/qa-jira-integration/SKILL.md +135 -0
- package/skills/qa-jira-integration/references/api-patterns.md +143 -0
- package/skills/qa-jira-integration/references/field-mapping.md +79 -0
- package/skills/qa-jira-integration/references/xray-integration.md +85 -0
- package/skills/qa-jmeter-writer/SKILL.md +171 -0
- package/skills/qa-jmeter-writer/references/best-practices.md +157 -0
- package/skills/qa-jmeter-writer/references/config.md +204 -0
- package/skills/qa-jmeter-writer/references/patterns.md +242 -0
- package/skills/qa-junit5-writer/SKILL.md +157 -0
- package/skills/qa-junit5-writer/references/assertions.md +118 -0
- package/skills/qa-junit5-writer/references/config.md +97 -0
- package/skills/qa-junit5-writer/references/patterns.md +162 -0
- package/skills/qa-k6-writer/SKILL.md +155 -0
- package/skills/qa-k6-writer/references/best-practices.md +236 -0
- package/skills/qa-k6-writer/references/config.md +219 -0
- package/skills/qa-k6-writer/references/patterns.md +304 -0
- package/skills/qa-linear-integration/SKILL.md +137 -0
- package/skills/qa-linear-integration/references/api-patterns.md +249 -0
- package/skills/qa-linear-integration/references/field-mapping.md +121 -0
- package/skills/qa-locust-writer/SKILL.md +151 -0
- package/skills/qa-locust-writer/references/best-practices.md +126 -0
- package/skills/qa-locust-writer/references/config.md +170 -0
- package/skills/qa-locust-writer/references/patterns.md +235 -0
- package/skills/qa-manual-test-designer/SKILL.md +145 -0
- package/skills/qa-manual-test-designer/references/exploratory-charters.md +138 -0
- package/skills/qa-manual-test-designer/references/personas.md +146 -0
- package/skills/qa-manual-test-designer/templates/exploratory-charter-template.md +47 -0
- package/skills/qa-manual-test-designer/templates/test-case-template.md +31 -0
- package/skills/qa-mobile-test-writer/SKILL.md +144 -0
- package/skills/qa-mobile-test-writer/references/best-practices.md +214 -0
- package/skills/qa-mobile-test-writer/references/config.md +309 -0
- package/skills/qa-mobile-test-writer/references/patterns.md +304 -0
- package/skills/qa-nfr-analyst/SKILL.md +177 -0
- package/skills/qa-nfr-analyst/references/iso-25010-model.md +159 -0
- package/skills/qa-nfr-analyst/references/owasp-wstg-baseline.md +202 -0
- package/skills/qa-nfr-analyst/references/wcag-checklist.md +184 -0
- package/skills/qa-nfr-analyst/templates/owasp-checklist-template.md +89 -0
- package/skills/qa-nfr-analyst/templates/wcag-checklist-template.md +48 -0
- package/skills/qa-orchestrator/SKILL.md +132 -0
- package/skills/qa-orchestrator/references/handoff-chains.md +105 -0
- package/skills/qa-orchestrator/references/pipeline-modes.md +115 -0
- package/skills/qa-orchestrator/references/scheduler-rules.md +84 -0
- package/skills/qa-pact-writer/SKILL.md +133 -0
- package/skills/qa-pact-writer/references/best-practices.md +100 -0
- package/skills/qa-pact-writer/references/config.md +135 -0
- package/skills/qa-pact-writer/references/patterns.md +161 -0
- package/skills/qa-plan-creator/SKILL.md +139 -0
- package/skills/qa-plan-creator/references/introduction-plan.md +43 -0
- package/skills/qa-plan-creator/references/migration-plan.md +44 -0
- package/skills/qa-plan-creator/references/onboarding-plan.md +46 -0
- package/skills/qa-plan-creator/references/performance-plan.md +44 -0
- package/skills/qa-plan-creator/references/regression-plan.md +45 -0
- package/skills/qa-plan-creator/references/release-plan.md +45 -0
- package/skills/qa-plan-creator/references/sprint-plan.md +44 -0
- package/skills/qa-plan-creator/references/test-plan.md +59 -0
- package/skills/qa-plan-creator/references/uat-plan.md +43 -0
- package/skills/qa-plan-creator/templates/checklist-template.md +36 -0
- package/skills/qa-plan-creator/templates/regression-checklist-template.md +49 -0
- package/skills/qa-plan-creator/templates/release-checklist-template.md +46 -0
- package/skills/qa-plan-creator/templates/test-plan-template.md +74 -0
- package/skills/qa-playwright-py-writer/SKILL.md +156 -0
- package/skills/qa-playwright-py-writer/references/best-practices.md +194 -0
- package/skills/qa-playwright-py-writer/references/config.md +195 -0
- package/skills/qa-playwright-py-writer/references/patterns.md +212 -0
- package/skills/qa-playwright-ts-writer/SKILL.md +151 -0
- package/skills/qa-playwright-ts-writer/references/assertions.md +109 -0
- package/skills/qa-playwright-ts-writer/references/best-practices.md +191 -0
- package/skills/qa-playwright-ts-writer/references/config.md +144 -0
- package/skills/qa-playwright-ts-writer/references/patterns.md +171 -0
- package/skills/qa-pytest-writer/SKILL.md +145 -0
- package/skills/qa-pytest-writer/references/assertions.md +149 -0
- package/skills/qa-pytest-writer/references/best-practices.md +97 -0
- package/skills/qa-pytest-writer/references/config.md +176 -0
- package/skills/qa-pytest-writer/references/patterns.md +251 -0
- package/skills/qa-qase-integration/SKILL.md +149 -0
- package/skills/qa-qase-integration/references/api-reference.md +354 -0
- package/skills/qa-qase-integration/references/ci-integration.md +196 -0
- package/skills/qa-qase-integration/references/field-mapping.md +157 -0
- package/skills/qa-requirements-generator/SKILL.md +152 -0
- package/skills/qa-requirements-generator/references/iso-29148-structure.md +153 -0
- package/skills/qa-requirements-generator/references/requirement-patterns.md +278 -0
- package/skills/qa-rest-assured-writer/SKILL.md +137 -0
- package/skills/qa-rest-assured-writer/references/best-practices.md +50 -0
- package/skills/qa-rest-assured-writer/references/config.md +124 -0
- package/skills/qa-rest-assured-writer/references/patterns.md +192 -0
- package/skills/qa-risk-analyzer/SKILL.md +158 -0
- package/skills/qa-risk-analyzer/references/impact-analysis.md +133 -0
- package/skills/qa-risk-analyzer/references/risk-factors.md +123 -0
- package/skills/qa-robot-framework-writer/SKILL.md +147 -0
- package/skills/qa-robot-framework-writer/references/best-practices.md +249 -0
- package/skills/qa-robot-framework-writer/references/config.md +204 -0
- package/skills/qa-robot-framework-writer/references/libraries.md +273 -0
- package/skills/qa-robot-framework-writer/references/patterns.md +216 -0
- package/skills/qa-security-test-writer/SKILL.md +123 -0
- package/skills/qa-security-test-writer/references/best-practices.md +155 -0
- package/skills/qa-security-test-writer/references/owasp-top10.md +331 -0
- package/skills/qa-security-test-writer/references/zap-config.md +258 -0
- package/skills/qa-selenium-java-writer/SKILL.md +143 -0
- package/skills/qa-selenium-java-writer/references/best-practices.md +59 -0
- package/skills/qa-selenium-java-writer/references/config.md +143 -0
- package/skills/qa-selenium-java-writer/references/patterns.md +170 -0
- package/skills/qa-selenium-py-writer/SKILL.md +150 -0
- package/skills/qa-selenium-py-writer/references/best-practices.md +175 -0
- package/skills/qa-selenium-py-writer/references/config.md +224 -0
- package/skills/qa-selenium-py-writer/references/patterns.md +255 -0
- package/skills/qa-shortcut-integration/SKILL.md +143 -0
- package/skills/qa-shortcut-integration/references/api-patterns.md +126 -0
- package/skills/qa-shortcut-integration/references/field-mapping.md +66 -0
- package/skills/qa-spec-auditor/SKILL.md +162 -0
- package/skills/qa-spec-auditor/references/audit-checklist.md +144 -0
- package/skills/qa-spec-auditor/references/drift-patterns.md +207 -0
- package/skills/qa-spec-writer/SKILL.md +143 -0
- package/skills/qa-spec-writer/references/gherkin-guide.md +253 -0
- package/skills/qa-spec-writer/references/specification-patterns.md +274 -0
- package/skills/qa-spring-test-writer/SKILL.md +170 -0
- package/skills/qa-spring-test-writer/references/best-practices.md +57 -0
- package/skills/qa-spring-test-writer/references/config.md +179 -0
- package/skills/qa-spring-test-writer/references/patterns.md +235 -0
- package/skills/qa-supertest-writer/SKILL.md +150 -0
- package/skills/qa-supertest-writer/references/assertions.md +192 -0
- package/skills/qa-supertest-writer/references/best-practices.md +102 -0
- package/skills/qa-supertest-writer/references/config.md +166 -0
- package/skills/qa-supertest-writer/references/patterns.md +242 -0
- package/skills/qa-task-creator/SKILL.md +142 -0
- package/skills/qa-task-creator/references/linking-patterns.md +127 -0
- package/skills/qa-task-creator/references/task-types.md +169 -0
- package/skills/qa-task-creator/templates/task-template.md +24 -0
- package/skills/qa-test-doc-compiler/SKILL.md +114 -0
- package/skills/qa-test-doc-compiler/references/agile-tailoring.md +220 -0
- package/skills/qa-test-doc-compiler/references/iso-29119-3-documents.md +302 -0
- package/skills/qa-test-healer/SKILL.md +101 -0
- package/skills/qa-test-healer/references/diagnosis-patterns.md +142 -0
- package/skills/qa-test-healer/references/fix-strategies.md +177 -0
- package/skills/qa-test-reporter/SKILL.md +130 -0
- package/skills/qa-test-reporter/references/best-practices.md +162 -0
- package/skills/qa-test-reporter/references/iso-29119-reports.md +236 -0
- package/skills/qa-test-reporter/references/report-formats.md +287 -0
- package/skills/qa-test-reviewer/SKILL.md +142 -0
- package/skills/qa-test-reviewer/references/anti-patterns.md +268 -0
- package/skills/qa-test-reviewer/references/review-checklist.md +93 -0
- package/skills/qa-test-strategy/SKILL.md +133 -0
- package/skills/qa-test-strategy/references/entry-exit-criteria.md +176 -0
- package/skills/qa-test-strategy/references/risk-matrix.md +102 -0
- package/skills/qa-test-strategy/references/testing-types.md +143 -0
- package/skills/qa-testcase-from-docs/SKILL.md +161 -0
- package/skills/qa-testcase-from-docs/references/test-case-format.md +196 -0
- package/skills/qa-testcase-from-docs/references/test-design-techniques.md +126 -0
- package/skills/qa-testcase-from-docs/templates/test-case-template.md +31 -0
- package/skills/qa-testcase-from-ui/SKILL.md +109 -0
- package/skills/qa-testcase-from-ui/references/ui-element-patterns.md +126 -0
- package/skills/qa-testcase-from-ui/references/visual-analysis-guide.md +146 -0
- package/skills/qa-testcase-from-ui/templates/test-case-template.md +31 -0
- package/skills/qa-visual-regression-writer/SKILL.md +175 -0
- package/skills/qa-visual-regression-writer/references/best-practices.md +154 -0
- package/skills/qa-visual-regression-writer/references/config.md +220 -0
- package/skills/qa-visual-regression-writer/references/patterns.md +213 -0
- package/skills/qa-vitest-writer/SKILL.md +141 -0
- package/skills/qa-vitest-writer/references/assertions.md +105 -0
- package/skills/qa-vitest-writer/references/best-practices.md +62 -0
- package/skills/qa-vitest-writer/references/config.md +127 -0
- package/skills/qa-vitest-writer/references/patterns.md +141 -0
- package/skills/qa-webdriverio-writer/SKILL.md +145 -0
- package/skills/qa-webdriverio-writer/references/best-practices.md +176 -0
- package/skills/qa-webdriverio-writer/references/config.md +240 -0
- package/skills/qa-webdriverio-writer/references/patterns.md +269 -0
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# Coverage Dimensions Reference
|
|
2
|
+
|
|
3
|
+
Detailed reference for each coverage dimension with measurement methods per ISO/IEC/IEEE 29119 and industry practice.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. Requirements/Model Coverage (RTM)
|
|
8
|
+
|
|
9
|
+
### Definition
|
|
10
|
+
|
|
11
|
+
Tracks which requirements have associated test models and test cases, and whether those tests have been executed. Ensures every requirement is verifiable.
|
|
12
|
+
|
|
13
|
+
### RTM Structure
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
Requirement ID → Test Model → Test Case(s) → Execution Status
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
| Req ID | Test Model | Test Case(s) | Execution |
|
|
20
|
+
|--------|------------|--------------|-----------|
|
|
21
|
+
| REQ-001 | EP: email validation | TC-001, TC-002 | Pass |
|
|
22
|
+
| REQ-002 | State: login flow | TC-003..006 | Pass |
|
|
23
|
+
| REQ-003 | — | — | **Uncovered** |
|
|
24
|
+
|
|
25
|
+
### Measurement Method
|
|
26
|
+
|
|
27
|
+
1. **List all requirements** with unique IDs (from qa-requirements-generator or spec)
|
|
28
|
+
2. **Map each requirement** to test model(s) and test case(s)
|
|
29
|
+
3. **Compute coverage:** `Covered requirements / Total requirements × 100%`
|
|
30
|
+
4. **Identify gaps:** Requirements with no test case or no execution
|
|
31
|
+
|
|
32
|
+
### Gap Types
|
|
33
|
+
|
|
34
|
+
| Gap Type | Description | Priority |
|
|
35
|
+
|----------|-------------|----------|
|
|
36
|
+
| No test case | Requirement has no linked test | High |
|
|
37
|
+
| No execution | Test exists but not run | Medium |
|
|
38
|
+
| Stale link | Test case outdated or removed | Medium |
|
|
39
|
+
|
|
40
|
+
### Tools
|
|
41
|
+
|
|
42
|
+
- Spreadsheets, RTM templates
|
|
43
|
+
- Test management (Zephyr, TestRail, qTest) with traceability
|
|
44
|
+
- qa-testcase-from-docs for RTM generation
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## 2. Technique Coverage (ISO 29119-4)
|
|
49
|
+
|
|
50
|
+
### Definition
|
|
51
|
+
|
|
52
|
+
Ensures multiple test design techniques are applied across the system. Single-technique testing (e.g., only equivalence partitioning) may miss defects that other techniques would catch.
|
|
53
|
+
|
|
54
|
+
### ISO 29119-4 Techniques
|
|
55
|
+
|
|
56
|
+
| Technique | Abbreviation | When to Use |
|
|
57
|
+
|-----------|--------------|-------------|
|
|
58
|
+
| Equivalence Partitioning | EP | Input domains, validation |
|
|
59
|
+
| Boundary Value Analysis | BVA | Numeric ranges, limits |
|
|
60
|
+
| Decision Table | DT | Business rules, conditions |
|
|
61
|
+
| State Transition | ST | Workflows, lifecycles |
|
|
62
|
+
| Use Case | UC | User flows, scenarios |
|
|
63
|
+
| Classification Tree | CT | Combinatorial, configs |
|
|
64
|
+
|
|
65
|
+
### Measurement Method
|
|
66
|
+
|
|
67
|
+
1. **Tag each test case** with technique(s) used (EP, BVA, DT, ST, UC, CT)
|
|
68
|
+
2. **Per requirement or module:** Count distinct techniques applied
|
|
69
|
+
3. **Compute coverage:** `Requirements with ≥2 techniques / Total × 100%` (or project-defined threshold)
|
|
70
|
+
4. **Identify gaps:** Modules with only one technique or none
|
|
71
|
+
|
|
72
|
+
### Technique Matrix Example
|
|
73
|
+
|
|
74
|
+
| Module | EP | BVA | DT | ST | UC | Techniques Used |
|
|
75
|
+
|--------|----|----|----|----|----|-----------------|
|
|
76
|
+
| auth | ✓ | ✓ | ✓ | — | ✓ | 4 |
|
|
77
|
+
| checkout | ✓ | — | — | — | — | 1 (gap) |
|
|
78
|
+
| search | ✓ | ✓ | ✓ | — | ✓ | 4 |
|
|
79
|
+
|
|
80
|
+
### Gap Types
|
|
81
|
+
|
|
82
|
+
| Gap Type | Description | Priority |
|
|
83
|
+
|----------|-------------|----------|
|
|
84
|
+
| No technique | Test not tagged | Medium |
|
|
85
|
+
| Single technique | Only EP or only BVA | Medium |
|
|
86
|
+
| Missing for domain | BVA missing for numeric fields | High |
|
|
87
|
+
|
|
88
|
+
### Reference
|
|
89
|
+
|
|
90
|
+
- qa-testcase-from-docs `references/test-design-techniques.md`
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## 3. Code Coverage
|
|
95
|
+
|
|
96
|
+
### Definition
|
|
97
|
+
|
|
98
|
+
Measures which lines, branches, conditions, and functions of the source code are executed by tests. Complements requirements and technique coverage by revealing untested implementation.
|
|
99
|
+
|
|
100
|
+
### Coverage Types
|
|
101
|
+
|
|
102
|
+
| Type | Description | Typical Target |
|
|
103
|
+
|------|-------------|----------------|
|
|
104
|
+
| **Line** | % of executable lines run | 70–80% |
|
|
105
|
+
| **Branch** | % of decision branches (if/else) taken | 60–80% |
|
|
106
|
+
| **Condition** | % of compound conditions (a && b) fully exercised | 50–70% |
|
|
107
|
+
| **Function** | % of functions called | 80–90% |
|
|
108
|
+
|
|
109
|
+
### Measurement Method
|
|
110
|
+
|
|
111
|
+
1. **Instrument code** and run tests (see `references/tools.md`)
|
|
112
|
+
2. **Parse coverage report** (Istanbul, JaCoCo, coverage.py, SonarQube)
|
|
113
|
+
3. **Aggregate by module/package** for heatmap
|
|
114
|
+
4. **Identify gaps:** Files or modules below threshold; 0% coverage areas
|
|
115
|
+
|
|
116
|
+
### Tool Mapping by Language
|
|
117
|
+
|
|
118
|
+
| Language | Primary Tool | Report Format |
|
|
119
|
+
|----------|--------------|---------------|
|
|
120
|
+
| JavaScript/TypeScript | Istanbul (c8, nyc), V8 | JSON, LCOV, HTML |
|
|
121
|
+
| Java | JaCoCo | XML, HTML, CSV |
|
|
122
|
+
| Python | coverage.py | XML, HTML, JSON |
|
|
123
|
+
| .NET | Coverlet, OpenCover | XML, Cobertura |
|
|
124
|
+
| Multi-language | SonarQube | Sonar format |
|
|
125
|
+
|
|
126
|
+
### Gap Types
|
|
127
|
+
|
|
128
|
+
| Gap Type | Description | Priority |
|
|
129
|
+
|----------|-------------|----------|
|
|
130
|
+
| 0% coverage | Entire file/module untested | High (if critical) |
|
|
131
|
+
| Below threshold | Line coverage < project target | Medium |
|
|
132
|
+
| Branch gap | Condition not fully exercised | Medium |
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## Cross-Dimension Analysis
|
|
137
|
+
|
|
138
|
+
Combine dimensions for richer insights:
|
|
139
|
+
|
|
140
|
+
| Scenario | Interpretation |
|
|
141
|
+
|----------|----------------|
|
|
142
|
+
| High req, low code | Requirements covered but implementation gaps; possible dead code or missing automation |
|
|
143
|
+
| High code, low req | Code well-tested but not traced to requirements; traceability gap |
|
|
144
|
+
| High req+code, low technique | May lack variety; consider EP, BVA, DT, ST for same areas |
|
|
145
|
+
| All low | Systemic gap; prioritize by risk |
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## Risk-Based Prioritization
|
|
150
|
+
|
|
151
|
+
Apply risk (from qa-test-strategy `references/risk-matrix.md`) to prioritize gaps:
|
|
152
|
+
|
|
153
|
+
- **High-risk + uncovered** → First priority
|
|
154
|
+
- **High-risk + low technique** → Add technique variety
|
|
155
|
+
- **Low-risk + uncovered** → Defer or accept
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
# Coverage Tools Reference
|
|
2
|
+
|
|
3
|
+
Reference for code coverage tools: Istanbul, V8, JaCoCo, coverage.py, and SonarQube. Use for parsing reports and configuring coverage analysis.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## JavaScript / TypeScript
|
|
8
|
+
|
|
9
|
+
### Istanbul (nyc / c8)
|
|
10
|
+
|
|
11
|
+
**Purpose:** Line, branch, function, statement coverage for Node.js and browser tests.
|
|
12
|
+
|
|
13
|
+
**Install:**
|
|
14
|
+
```bash
|
|
15
|
+
npm install -D c8
|
|
16
|
+
# or
|
|
17
|
+
npm install -D nyc
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
**Run:**
|
|
21
|
+
```bash
|
|
22
|
+
c8 npm test
|
|
23
|
+
# or
|
|
24
|
+
nyc npm test
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**Report formats:** JSON, LCOV, HTML, text-summary
|
|
28
|
+
|
|
29
|
+
**Output location:** `coverage/` (default)
|
|
30
|
+
|
|
31
|
+
**Key config (package.json or .nycrc):**
|
|
32
|
+
```json
|
|
33
|
+
{
|
|
34
|
+
"coverage": {
|
|
35
|
+
"reporter": ["text", "lcov", "html"],
|
|
36
|
+
"exclude": ["**/*.test.js", "**/node_modules/**"]
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### V8 Native Coverage
|
|
42
|
+
|
|
43
|
+
**Purpose:** Native V8 coverage (Chrome/Node); often used with Vitest, Jest, or Playwright.
|
|
44
|
+
|
|
45
|
+
**Vitest:**
|
|
46
|
+
```javascript
|
|
47
|
+
// vitest.config.ts
|
|
48
|
+
export default {
|
|
49
|
+
test: {
|
|
50
|
+
coverage: {
|
|
51
|
+
provider: 'v8',
|
|
52
|
+
reporter: ['text', 'json', 'html'],
|
|
53
|
+
exclude: ['node_modules', '**/*.spec.ts']
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**Jest (with v8):**
|
|
60
|
+
```javascript
|
|
61
|
+
// jest.config.js
|
|
62
|
+
module.exports = {
|
|
63
|
+
collectCoverageFrom: ['src/**/*.{js,ts}'],
|
|
64
|
+
coverageProvider: 'v8',
|
|
65
|
+
coverageReporters: ['text', 'lcov', 'html']
|
|
66
|
+
};
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**Report formats:** V8 format, LCOV, HTML
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## Java
|
|
74
|
+
|
|
75
|
+
### JaCoCo
|
|
76
|
+
|
|
77
|
+
**Purpose:** Line, branch, instruction coverage for JVM languages (Java, Kotlin, Scala).
|
|
78
|
+
|
|
79
|
+
**Maven:**
|
|
80
|
+
```xml
|
|
81
|
+
<plugin>
|
|
82
|
+
<groupId>org.jacoco</groupId>
|
|
83
|
+
<artifactId>jacoco-maven-plugin</artifactId>
|
|
84
|
+
<version>0.8.11</version>
|
|
85
|
+
<executions>
|
|
86
|
+
<execution>
|
|
87
|
+
<goals><goal>prepare-agent</goal></goals>
|
|
88
|
+
<configuration>
|
|
89
|
+
<destFile>${project.build.directory}/jacoco.exec</destFile>
|
|
90
|
+
</configuration>
|
|
91
|
+
</execution>
|
|
92
|
+
<execution>
|
|
93
|
+
<id>report</id>
|
|
94
|
+
<phase>test</phase>
|
|
95
|
+
<goals><goal>report</goal></goals>
|
|
96
|
+
</execution>
|
|
97
|
+
</executions>
|
|
98
|
+
</plugin>
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**Gradle:**
|
|
102
|
+
```groovy
|
|
103
|
+
plugins {
|
|
104
|
+
id 'jacoco'
|
|
105
|
+
}
|
|
106
|
+
jacoco {
|
|
107
|
+
toolVersion = "0.8.11"
|
|
108
|
+
}
|
|
109
|
+
test {
|
|
110
|
+
finalizedBy jacocoTestReport
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
**Report formats:** XML, HTML, CSV
|
|
115
|
+
|
|
116
|
+
**Output:** `target/site/jacoco/` (Maven), `build/reports/jacoco/` (Gradle)
|
|
117
|
+
|
|
118
|
+
**Parsing:** XML report contains `<package>`, `<class>`, `<counter type="LINE">` etc.
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## Python
|
|
123
|
+
|
|
124
|
+
### coverage.py
|
|
125
|
+
|
|
126
|
+
**Purpose:** Line and branch coverage for Python.
|
|
127
|
+
|
|
128
|
+
**Install:**
|
|
129
|
+
```bash
|
|
130
|
+
pip install coverage
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
**Run:**
|
|
134
|
+
```bash
|
|
135
|
+
coverage run -m pytest
|
|
136
|
+
coverage report
|
|
137
|
+
coverage html
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
**Config (.coveragerc or pyproject.toml):**
|
|
141
|
+
```ini
|
|
142
|
+
[run]
|
|
143
|
+
source = src
|
|
144
|
+
omit = */tests/*, */venv/*
|
|
145
|
+
|
|
146
|
+
[report]
|
|
147
|
+
exclude_lines =
|
|
148
|
+
pragma: no cover
|
|
149
|
+
def __repr__
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
**Report formats:** XML (Cobertura), HTML, JSON
|
|
153
|
+
|
|
154
|
+
**Output:** `htmlcov/`, `coverage.xml`
|
|
155
|
+
|
|
156
|
+
**Branch coverage:**
|
|
157
|
+
```bash
|
|
158
|
+
coverage run --branch -m pytest
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## SonarQube
|
|
164
|
+
|
|
165
|
+
**Purpose:** Centralized quality and coverage across languages. Aggregates coverage from Istanbul, JaCoCo, coverage.py, etc.
|
|
166
|
+
|
|
167
|
+
**Setup:**
|
|
168
|
+
1. Run SonarQube server (Docker or standalone)
|
|
169
|
+
2. Configure `sonar-project.properties`:
|
|
170
|
+
```properties
|
|
171
|
+
sonar.projectKey=my-project
|
|
172
|
+
sonar.sources=src
|
|
173
|
+
sonar.tests=test
|
|
174
|
+
sonar.javascript.lcov.reportPaths=coverage/lcov.info
|
|
175
|
+
sonar.java.jacoco.reportPaths=target/site/jacoco/jacoco.xml
|
|
176
|
+
sonar.python.coverage.reportPaths=coverage.xml
|
|
177
|
+
```
|
|
178
|
+
3. Run scanner: `sonar-scanner`
|
|
179
|
+
|
|
180
|
+
**Coverage sources:** LCOV (JS/TS), JaCoCo XML (Java), Cobertura/coverage.xml (Python)
|
|
181
|
+
|
|
182
|
+
**Use for:** Unified dashboard, quality gates, trend tracking
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## Report Parsing Tips
|
|
187
|
+
|
|
188
|
+
| Tool | Key File | Structure |
|
|
189
|
+
|------|----------|-----------|
|
|
190
|
+
| Istanbul/c8 | coverage/coverage-final.json | `[file path]: { s: statements, f: functions, b: branches }` |
|
|
191
|
+
| JaCoCo | jacoco.xml | `<package name="">` → `<class>` → `<counter type="LINE" missed="..." covered="..."/>` |
|
|
192
|
+
| coverage.py | coverage.xml | Cobertura format: `<packages>` → `<package>` → `<classes>` → `<line number="..." hits="..."/>` |
|
|
193
|
+
| SonarQube | API / scanner output | Use Sonar API or scanner for aggregated metrics |
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## CI Integration
|
|
198
|
+
|
|
199
|
+
| CI | Example |
|
|
200
|
+
|----|---------|
|
|
201
|
+
| GitHub Actions | `npm run test:coverage` → upload `coverage/` artifact |
|
|
202
|
+
| GitLab CI | `coverage: '/Lines:\s+(\d+\.?\d*)%/'` in job |
|
|
203
|
+
| Jenkins | Publish HTML/LCOV/XML; use Coverage plugin |
|
|
204
|
+
| Azure Pipelines | Publish Code Coverage task with format (Cobertura, JaCoCo) |
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: qa-cypress-writer
|
|
3
|
+
description: Generate Cypress E2E and component tests for TypeScript with time-travel debugging, cy.intercept for network mocking, and component testing via cy.mount.
|
|
4
|
+
output_dir: tests/e2e
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# QA Cypress Writer
|
|
8
|
+
|
|
9
|
+
## Purpose
|
|
10
|
+
|
|
11
|
+
Write Cypress E2E and component tests from test case specifications. Transform structured test cases into executable TypeScript test files with proper selectors, network mocking, and component isolation.
|
|
12
|
+
|
|
13
|
+
## Trigger Phrases
|
|
14
|
+
|
|
15
|
+
- "Write Cypress tests for [feature/page]"
|
|
16
|
+
- "Generate Cypress E2E tests from test cases"
|
|
17
|
+
- "Create Cypress component tests for [component]"
|
|
18
|
+
- "Add Cypress tests with cy.intercept for [API]"
|
|
19
|
+
- "Cypress tests with cy.mount for [React/Vue component]"
|
|
20
|
+
- "Cypress E2E test file for [flow]"
|
|
21
|
+
- "Cypress custom commands for [login/fillForm]"
|
|
22
|
+
|
|
23
|
+
## Test Types
|
|
24
|
+
|
|
25
|
+
| Type | Scope | When to Use |
|
|
26
|
+
|------|-------|-------------|
|
|
27
|
+
| **E2E** | Full user flows, page navigation | Critical paths, user journeys |
|
|
28
|
+
| **Component** | Isolated UI components | React/Vue/Angular/Svelte components |
|
|
29
|
+
|
|
30
|
+
## Workflow
|
|
31
|
+
|
|
32
|
+
1. **Read test cases** — From Phase 2 (qa-testcase-from-docs, qa-manual-test-designer, qa-browser-data-collector)
|
|
33
|
+
2. **Analyze target** — Page structure, API endpoints, component props/events
|
|
34
|
+
3. **Generate test files** — Create `*.cy.ts` in `cypress/e2e/` or `cypress/component/`
|
|
35
|
+
4. **Add intercepts/fixtures** — `cy.intercept()`, `cy.fixture()` for network control
|
|
36
|
+
5. **Verify selectors** — Prefer `data-cy` attributes; avoid brittle CSS
|
|
37
|
+
|
|
38
|
+
## Context7 MCP
|
|
39
|
+
|
|
40
|
+
Uses Context7 MCP to fetch current Cypress documentation when needed. Query for Cypress API, commands, or configuration when patterns are unclear.
|
|
41
|
+
|
|
42
|
+
## E2E Testing
|
|
43
|
+
|
|
44
|
+
- **Navigation:** `cy.visit()`, `cy.go()`, `cy.reload()`
|
|
45
|
+
- **Queries:** `cy.get()`, `cy.contains()`, `cy.find()` — chainable, retry-able
|
|
46
|
+
- **Actions:** `cy.click()`, `cy.type()`, `cy.clear()`, `cy.select()`, `cy.check()`
|
|
47
|
+
- **Chained commands** — Each command retries until timeout; enables time-travel debugging
|
|
48
|
+
- **Retry-ability** — Cypress automatically retries assertions and queries
|
|
49
|
+
|
|
50
|
+
## Component Testing
|
|
51
|
+
|
|
52
|
+
- **cy.mount()** — Mount React/Vue/Angular/Svelte components in isolation
|
|
53
|
+
- **Props/events/slots** — Test component behavior without full app
|
|
54
|
+
- **Dev server** — Uses `component.devServer` in config (Vite, Webpack, etc.)
|
|
55
|
+
|
|
56
|
+
## Network Mocking
|
|
57
|
+
|
|
58
|
+
- **cy.intercept()** — Stub, spy, or wait for HTTP requests
|
|
59
|
+
- **Fixtures** — `cy.fixture()` for response data; `cy.intercept('GET', '/api/users', { fixture: 'users.json' })`
|
|
60
|
+
- **Aliases** — `cy.intercept('GET', '/api/users').as('getUsers')`; `cy.wait('@getUsers')`
|
|
61
|
+
|
|
62
|
+
## Custom Commands
|
|
63
|
+
|
|
64
|
+
- **Cypress.Commands.add()** — Reusable actions: `cy.login()`, `cy.fillForm()`, `cy.logout()`
|
|
65
|
+
- **Declare in cypress/support/commands.ts** — Extend Cypress namespace for TypeScript
|
|
66
|
+
|
|
67
|
+
## Key Patterns
|
|
68
|
+
|
|
69
|
+
- **Structure:** `describe` / `it`, `beforeEach` / `afterEach`
|
|
70
|
+
- **Auth:** `cy.session()` for login state caching (Cypress 8+)
|
|
71
|
+
- **Screenshots:** `cy.screenshot()` for debugging; auto on failure
|
|
72
|
+
- **Data attributes:** `data-cy="submit-btn"` for stable selectors
|
|
73
|
+
- **Assertions:** Explicit `should()` / `expect()`; avoid implicit passes
|
|
74
|
+
|
|
75
|
+
## Configuration
|
|
76
|
+
|
|
77
|
+
- **cypress.config.ts** — `baseUrl`, `viewportWidth`/`viewportHeight`, `video`, `retries`, `component.devServer`
|
|
78
|
+
- **Support files** — `cypress/support/e2e.ts`, `commands.ts`
|
|
79
|
+
|
|
80
|
+
See `references/config.md` for full configuration guide.
|
|
81
|
+
|
|
82
|
+
## File Naming
|
|
83
|
+
|
|
84
|
+
- `cypress/e2e/{feature}.cy.ts` — E2E tests
|
|
85
|
+
- `cypress/component/{Component}.cy.tsx` — Component tests
|
|
86
|
+
|
|
87
|
+
## References
|
|
88
|
+
|
|
89
|
+
- `references/patterns.md` — E2E flows, component mounting, custom commands, fixtures, aliases
|
|
90
|
+
- `references/assertions.md` — should, expect, assert patterns (Chai)
|
|
91
|
+
- `references/config.md` — cypress.config.ts, env, plugins, support files
|
|
92
|
+
- `references/best-practices.md` — data-cy, anti-patterns, flake prevention, CI
|
|
93
|
+
|
|
94
|
+
## Scope
|
|
95
|
+
|
|
96
|
+
**Can do (autonomous):**
|
|
97
|
+
- Generate Cypress E2E and component tests from test cases
|
|
98
|
+
- Add `cy.intercept()` for API stubbing/spying
|
|
99
|
+
- Create custom commands in `commands.ts`
|
|
100
|
+
- Use `cy.fixture()` and `cy.session()` where appropriate
|
|
101
|
+
- Configure `cypress.config.ts` for baseUrl, viewport, retries
|
|
102
|
+
- Add `data-cy` selectors in generated tests (recommend adding to app if missing)
|
|
103
|
+
|
|
104
|
+
**Cannot do (requires confirmation):**
|
|
105
|
+
- Modify production code to add `data-cy` attributes
|
|
106
|
+
- Change existing Cypress config without user approval
|
|
107
|
+
- Add tests for flows/components not in scope
|
|
108
|
+
|
|
109
|
+
**Will not do (out of scope):**
|
|
110
|
+
- Unit tests (use qa-jest-writer)
|
|
111
|
+
- Visual regression (use dedicated tools)
|
|
112
|
+
- Modify application deployment or runtime
|
|
113
|
+
|
|
114
|
+
## Quality Checklist
|
|
115
|
+
|
|
116
|
+
- [ ] No `cy.wait(ms)` — use `cy.wait('@alias')` or assertions instead
|
|
117
|
+
- [ ] Use `data-cy` attributes for selectors where possible
|
|
118
|
+
- [ ] Assertions explicit — every meaningful step has assertion
|
|
119
|
+
- [ ] No cross-test dependencies — tests run in any order
|
|
120
|
+
- [ ] Proper cleanup — no leftover state between tests
|
|
121
|
+
- [ ] Intercepts scoped — avoid global intercepts that leak
|
|
122
|
+
- [ ] Descriptive test names — "should display error when login fails"
|
|
123
|
+
|
|
124
|
+
## Troubleshooting
|
|
125
|
+
|
|
126
|
+
| Symptom | Likely Cause | Fix |
|
|
127
|
+
|---------|--------------|-----|
|
|
128
|
+
| Element not found | Selector too brittle or timing | Use `data-cy`; ensure element exists before action; increase timeout if needed |
|
|
129
|
+
| cy.wait(ms) flakiness | Arbitrary delays | Replace with `cy.wait('@alias')` or `should()` assertions |
|
|
130
|
+
| Intercept not matching | URL/pattern mismatch | Use `cy.intercept('**/api/users*')` or exact URL; check method |
|
|
131
|
+
| Session not persisting | cy.session misconfigured | Ensure `cy.session()` in `beforeEach`; validate cache key |
|
|
132
|
+
| Component mount fails | Missing provider/wrapper | Add providers in `cy.mount(<Provider><Component /></Provider>)` |
|
|
133
|
+
| Cross-origin errors | Navigating to different domain | Use `cy.origin()` for cross-origin flows |
|
|
134
|
+
| Timeout on assertion | Element never meets condition | Verify selector; check if element is in iframe (not supported) |
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# Cypress / Chai Assertion Reference
|
|
2
|
+
|
|
3
|
+
Cypress uses Chai assertions. Two styles: `should` (BDD) and `expect` / `assert` (TDD).
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## should (BDD, chained)
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
cy.get('[data-cy="title"]').should('have.text', 'Welcome');
|
|
11
|
+
cy.get('input').should('have.value', 'test').and('be.visible');
|
|
12
|
+
cy.get('button').should('be.disabled').and('have.class', 'primary');
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## expect (TDD, explicit)
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
cy.get('[data-cy="count"]').then(($el) => {
|
|
21
|
+
expect($el.text()).to.eq('5');
|
|
22
|
+
expect($el).to.be.visible;
|
|
23
|
+
});
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## assert (TDD, explicit)
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
cy.get('body').then(($body) => {
|
|
32
|
+
assert.isTrue($body.find('[data-cy="success"]').length > 0);
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Common Assertions by Category
|
|
39
|
+
|
|
40
|
+
### DOM / Visibility
|
|
41
|
+
|
|
42
|
+
| Assertion | Example |
|
|
43
|
+
|-----------|---------|
|
|
44
|
+
| `be.visible` | `cy.get('el').should('be.visible')` |
|
|
45
|
+
| `be.hidden` | `cy.get('el').should('be.hidden')` |
|
|
46
|
+
| `exist` | `cy.get('el').should('exist')` |
|
|
47
|
+
| `not.exist` | `cy.get('el').should('not.exist')` |
|
|
48
|
+
|
|
49
|
+
### Text / Content
|
|
50
|
+
|
|
51
|
+
| Assertion | Example |
|
|
52
|
+
|-----------|---------|
|
|
53
|
+
| `have.text` | `cy.get('el').should('have.text', 'Hello')` |
|
|
54
|
+
| `contain` | `cy.get('el').should('contain', 'partial')` |
|
|
55
|
+
| `include.text` | `cy.get('el').should('include.text', 'partial')` |
|
|
56
|
+
|
|
57
|
+
### Attributes / Properties
|
|
58
|
+
|
|
59
|
+
| Assertion | Example |
|
|
60
|
+
|-----------|---------|
|
|
61
|
+
| `have.attr` | `cy.get('el').should('have.attr', 'href', '/home')` |
|
|
62
|
+
| `have.class` | `cy.get('el').should('have.class', 'active')` |
|
|
63
|
+
| `have.value` | `cy.get('input').should('have.value', 'typed')` |
|
|
64
|
+
| `have.css` | `cy.get('el').should('have.css', 'display', 'block')` |
|
|
65
|
+
|
|
66
|
+
### State
|
|
67
|
+
|
|
68
|
+
| Assertion | Example |
|
|
69
|
+
|-----------|---------|
|
|
70
|
+
| `be.disabled` | `cy.get('button').should('be.disabled')` |
|
|
71
|
+
| `be.enabled` | `cy.get('button').should('be.enabled')` |
|
|
72
|
+
| `be.checked` | `cy.get('checkbox').should('be.checked')` |
|
|
73
|
+
| `be.focused` | `cy.get('input').should('be.focused')` |
|
|
74
|
+
|
|
75
|
+
### Length / Count
|
|
76
|
+
|
|
77
|
+
| Assertion | Example |
|
|
78
|
+
|-----------|---------|
|
|
79
|
+
| `have.length` | `cy.get('li').should('have.length', 5)` |
|
|
80
|
+
| `have.length.greaterThan` | `cy.get('li').should('have.length.greaterThan', 0)` |
|
|
81
|
+
|
|
82
|
+
### URL
|
|
83
|
+
|
|
84
|
+
| Assertion | Example |
|
|
85
|
+
|-----------|---------|
|
|
86
|
+
| `include` | `cy.url().should('include', '/dashboard')` |
|
|
87
|
+
| `eq` | `cy.url().should('eq', 'https://app.example.com/')` |
|
|
88
|
+
|
|
89
|
+
### Negation
|
|
90
|
+
|
|
91
|
+
Prepend `not.`:
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
cy.get('el').should('not.be.visible');
|
|
95
|
+
cy.get('el').should('not.contain', 'Error');
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## Chaining Assertions
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
cy.get('[data-cy="card"]')
|
|
104
|
+
.should('be.visible')
|
|
105
|
+
.and('have.class', 'highlighted')
|
|
106
|
+
.and('contain', 'Success');
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## Custom Chai Assertions
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
chai.use((chai, utils) => {
|
|
115
|
+
chai.Assertion.addMethod('validEmail', function () {
|
|
116
|
+
const obj = this._obj;
|
|
117
|
+
const pass = /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(obj);
|
|
118
|
+
this.assert(pass, 'expected #{this} to be valid email', 'expected #{this} not to be valid email');
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
```
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Cypress Best Practices
|
|
2
|
+
|
|
3
|
+
## Selecting Elements
|
|
4
|
+
|
|
5
|
+
### Prefer data-cy Attributes
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
// Good — stable, test-specific
|
|
9
|
+
cy.get('[data-cy="submit-button"]').click();
|
|
10
|
+
cy.get('[data-cy="user-email"]').type('test@example.com');
|
|
11
|
+
|
|
12
|
+
// Avoid — brittle
|
|
13
|
+
cy.get('.btn-primary').click();
|
|
14
|
+
cy.get('#email').type('test@example.com');
|
|
15
|
+
cy.get('div > span:nth-child(2)').click();
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Add `data-cy` to production markup or via build step. Never rely solely on CSS classes or structure that may change.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Anti-Patterns to Avoid
|
|
23
|
+
|
|
24
|
+
### No cy.wait(ms)
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
// Bad — flaky, arbitrary delay
|
|
28
|
+
cy.wait(3000);
|
|
29
|
+
cy.get('[data-cy="results"]').click();
|
|
30
|
+
|
|
31
|
+
// Good — wait for condition or request
|
|
32
|
+
cy.intercept('GET', '/api/results').as('getResults');
|
|
33
|
+
cy.visit('/dashboard');
|
|
34
|
+
cy.wait('@getResults');
|
|
35
|
+
cy.get('[data-cy="results"]').should('be.visible').click();
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### No Cross-Test Dependencies
|
|
39
|
+
|
|
40
|
+
Each test must be independent. Do not rely on execution order or shared mutable state.
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
// Bad
|
|
44
|
+
let sharedId;
|
|
45
|
+
it('creates item', () => { sharedId = ...; });
|
|
46
|
+
it('edits item', () => { cy.visit(`/items/${sharedId}`); });
|
|
47
|
+
|
|
48
|
+
// Good
|
|
49
|
+
it('edits item', () => {
|
|
50
|
+
cy.login();
|
|
51
|
+
cy.createItemViaApi({ name: 'Test' }).then((id) => {
|
|
52
|
+
cy.visit(`/items/${id}`);
|
|
53
|
+
// ...
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Proper Cleanup
|
|
59
|
+
|
|
60
|
+
- Use `beforeEach` / `afterEach` for setup and teardown
|
|
61
|
+
- Use `cy.session()` for login to cache auth across tests
|
|
62
|
+
- Reset DB or use isolated test data when possible
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Flake Prevention
|
|
67
|
+
|
|
68
|
+
1. **Assert before acting** — Ensure element is ready before click/type
|
|
69
|
+
2. **Use aliases for async** — `cy.wait('@alias')` instead of fixed delays
|
|
70
|
+
3. **Retry-ability** — Chain assertions; Cypress retries until timeout
|
|
71
|
+
4. **Avoid testing third-party** — Mock external APIs with `cy.intercept`
|
|
72
|
+
5. **Stable selectors** — `data-cy` over classes/IDs that change
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## CI Setup
|
|
77
|
+
|
|
78
|
+
- Set `baseUrl` via `CYPRESS_BASE_URL` or `env.baseUrl`
|
|
79
|
+
- Use `retries: { runMode: 2 }` for transient failures
|
|
80
|
+
- Enable `video: true` and archive on failure
|
|
81
|
+
- Run in parallel with `cypress run --record` (Cypress Dashboard)
|
|
82
|
+
- Use `--config viewportWidth=1280` for consistent viewport
|