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,236 @@
|
|
|
1
|
+
# k6 Best Practices
|
|
2
|
+
|
|
3
|
+
## Realistic Load
|
|
4
|
+
|
|
5
|
+
### Think Time (sleep)
|
|
6
|
+
Simulate user think time between actions to avoid unrealistic burst patterns.
|
|
7
|
+
|
|
8
|
+
```javascript
|
|
9
|
+
import { sleep } from 'k6';
|
|
10
|
+
|
|
11
|
+
export default function () {
|
|
12
|
+
http.get('https://example.com/');
|
|
13
|
+
sleep(Math.random() * 3 + 1); // 1–4 seconds
|
|
14
|
+
http.get('https://example.com/dashboard');
|
|
15
|
+
sleep(2);
|
|
16
|
+
}
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Ramp Up Gradually
|
|
20
|
+
Avoid instant load spikes; use stages to ramp up and down.
|
|
21
|
+
|
|
22
|
+
```javascript
|
|
23
|
+
// Good: gradual ramp
|
|
24
|
+
stages: [
|
|
25
|
+
{ duration: '2m', target: 50 },
|
|
26
|
+
{ duration: '5m', target: 50 },
|
|
27
|
+
{ duration: '2m', target: 0 },
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
// Avoid: instant spike (unless testing spike scenario)
|
|
31
|
+
vus: 500,
|
|
32
|
+
duration: '1m',
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Correlation
|
|
38
|
+
|
|
39
|
+
Extract dynamic values from responses for subsequent requests.
|
|
40
|
+
|
|
41
|
+
```javascript
|
|
42
|
+
const loginRes = http.post('https://api.example.com/login', JSON.stringify(creds), {
|
|
43
|
+
headers: { 'Content-Type': 'application/json' },
|
|
44
|
+
});
|
|
45
|
+
const token = loginRes.json('access_token');
|
|
46
|
+
|
|
47
|
+
const apiRes = http.get('https://api.example.com/protected', {
|
|
48
|
+
headers: { Authorization: `Bearer ${token}` },
|
|
49
|
+
});
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Session Cookies
|
|
53
|
+
```javascript
|
|
54
|
+
const res = http.get('https://example.com/');
|
|
55
|
+
const cookies = res.cookies;
|
|
56
|
+
// Cookies automatically sent in subsequent requests from same VU
|
|
57
|
+
http.get('https://example.com/dashboard');
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Parameterization
|
|
63
|
+
|
|
64
|
+
### SharedArray (Memory-Efficient)
|
|
65
|
+
Use `SharedArray` for large datasets; data is shared across VUs.
|
|
66
|
+
|
|
67
|
+
```javascript
|
|
68
|
+
import { SharedArray } from 'k6/data';
|
|
69
|
+
|
|
70
|
+
const users = new SharedArray('users', function () {
|
|
71
|
+
return JSON.parse(open('./users.json'));
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
export default function () {
|
|
75
|
+
const user = users[__ITER % users.length];
|
|
76
|
+
// use user
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Regular Array (Small Data)
|
|
81
|
+
```javascript
|
|
82
|
+
const items = JSON.parse(open('./items.json'));
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### CSV
|
|
86
|
+
```javascript
|
|
87
|
+
import { SharedArray } from 'k6/data';
|
|
88
|
+
import papaparse from 'https://jslib.k6.io/papaparse/5.1.1/index.js';
|
|
89
|
+
|
|
90
|
+
const data = new SharedArray('csv', function () {
|
|
91
|
+
return papaparse.parse(open('./data.csv'), { header: true }).data;
|
|
92
|
+
});
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## CI Integration
|
|
98
|
+
|
|
99
|
+
### GitHub Actions
|
|
100
|
+
```yaml
|
|
101
|
+
name: k6 Performance Tests
|
|
102
|
+
on: [push]
|
|
103
|
+
jobs:
|
|
104
|
+
k6:
|
|
105
|
+
runs-on: ubuntu-latest
|
|
106
|
+
steps:
|
|
107
|
+
- uses: actions/checkout@v4
|
|
108
|
+
- uses: grafana/setup-k6-action@v1
|
|
109
|
+
with:
|
|
110
|
+
k6-version: v0.48.0
|
|
111
|
+
- name: Run k6
|
|
112
|
+
run: k6 run --out json=results.json tests/load/script.js
|
|
113
|
+
- name: Upload results
|
|
114
|
+
uses: actions/upload-artifact@v4
|
|
115
|
+
with:
|
|
116
|
+
name: k6-results
|
|
117
|
+
path: results.json
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Exit Code
|
|
121
|
+
k6 exits with code 0 if all thresholds pass, non-zero if any fail. CI can use this for gating.
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
k6 run script.js
|
|
125
|
+
echo $? # 0 = pass, 1 = fail
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Threshold Failure
|
|
129
|
+
```yaml
|
|
130
|
+
- name: Run k6
|
|
131
|
+
run: k6 run script.js
|
|
132
|
+
# Job fails automatically if thresholds fail
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## Script Structure
|
|
138
|
+
|
|
139
|
+
### Default Export
|
|
140
|
+
```javascript
|
|
141
|
+
export default function () {
|
|
142
|
+
// Main VU logic
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Scenario-Specific Functions
|
|
147
|
+
```javascript
|
|
148
|
+
export const options = {
|
|
149
|
+
scenarios: {
|
|
150
|
+
browse: { exec: 'browseFlow', ... },
|
|
151
|
+
api: { exec: 'apiFlow', ... },
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
export function browseFlow() { /* ... */ }
|
|
156
|
+
export function apiFlow() { /* ... */ }
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Setup and Teardown
|
|
160
|
+
```javascript
|
|
161
|
+
export function setup() {
|
|
162
|
+
// Run once before test; return data for default function
|
|
163
|
+
return { token: getAuthToken() };
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export default function (data) {
|
|
167
|
+
// Use data.token
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export function teardown(data) {
|
|
171
|
+
// Run once after test
|
|
172
|
+
}
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## Checks and Thresholds
|
|
178
|
+
|
|
179
|
+
### Use Both
|
|
180
|
+
- **Checks** — Per-request assertions; track success rate
|
|
181
|
+
- **Thresholds** — Pass/fail the entire run
|
|
182
|
+
|
|
183
|
+
```javascript
|
|
184
|
+
import { check } from 'k6';
|
|
185
|
+
import http from 'k6/http';
|
|
186
|
+
|
|
187
|
+
export const options = {
|
|
188
|
+
thresholds: {
|
|
189
|
+
checks: ['rate>0.95'],
|
|
190
|
+
http_req_duration: ['p(95)<200'],
|
|
191
|
+
},
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
export default function () {
|
|
195
|
+
const res = http.get('https://example.com/');
|
|
196
|
+
check(res, {
|
|
197
|
+
'status 200': (r) => r.status === 200,
|
|
198
|
+
'has body': (r) => r.body.length > 0,
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
## Avoid Anti-Patterns
|
|
206
|
+
|
|
207
|
+
| Anti-Pattern | Fix |
|
|
208
|
+
| ------------ | --- |
|
|
209
|
+
| No sleep between requests | Add `sleep()` for realistic pacing |
|
|
210
|
+
| Hardcoded URLs/secrets | Use `__ENV` or `options.env` |
|
|
211
|
+
| Single huge default function | Split into `group()` or scenario functions |
|
|
212
|
+
| Ignoring failed requests | Add `http_req_failed` threshold |
|
|
213
|
+
| No thresholds | Define at least `http_req_duration` and `http_req_failed` |
|
|
214
|
+
| Loading large JSON with `open()` in default | Use `SharedArray` for memory efficiency |
|
|
215
|
+
| Testing production without coordination | Use staging; coordinate with ops |
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
## Debugging
|
|
220
|
+
|
|
221
|
+
### Verbose Output
|
|
222
|
+
```bash
|
|
223
|
+
k6 run --verbose script.js
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### Single VU, Single Iteration
|
|
227
|
+
```bash
|
|
228
|
+
k6 run --vus 1 --iterations 1 script.js
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### HTTP Debug
|
|
232
|
+
```javascript
|
|
233
|
+
export const options = {
|
|
234
|
+
httpDebug: 'full', // Log all HTTP traffic
|
|
235
|
+
};
|
|
236
|
+
```
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
# k6 Configuration Reference
|
|
2
|
+
|
|
3
|
+
## Options Object
|
|
4
|
+
|
|
5
|
+
The `options` object configures test execution. Place at top of script or pass via CLI.
|
|
6
|
+
|
|
7
|
+
```javascript
|
|
8
|
+
export const options = {
|
|
9
|
+
vus: 10,
|
|
10
|
+
duration: '30s',
|
|
11
|
+
thresholds: {},
|
|
12
|
+
scenarios: {},
|
|
13
|
+
stages: [],
|
|
14
|
+
tags: {},
|
|
15
|
+
noConnectionReuse: false,
|
|
16
|
+
userAgent: 'k6',
|
|
17
|
+
insecureSkipTLSVerify: false,
|
|
18
|
+
tlsVersion: { min: 'tls1.2', max: 'tls1.3' },
|
|
19
|
+
};
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Scenarios
|
|
25
|
+
|
|
26
|
+
Define multiple execution patterns in a single test.
|
|
27
|
+
|
|
28
|
+
```javascript
|
|
29
|
+
export const options = {
|
|
30
|
+
scenarios: {
|
|
31
|
+
scenario_name: {
|
|
32
|
+
executor: 'constant-vus',
|
|
33
|
+
vus: 10,
|
|
34
|
+
duration: '5m',
|
|
35
|
+
exec: 'functionName',
|
|
36
|
+
startTime: '0s',
|
|
37
|
+
gracefulStop: '30s',
|
|
38
|
+
env: { MY_VAR: 'value' },
|
|
39
|
+
tags: { scenario: 'api' },
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Executor Reference
|
|
46
|
+
|
|
47
|
+
| Executor | Parameters |
|
|
48
|
+
| -------- | ---------- |
|
|
49
|
+
| shared-iterations | `iterations`, `vus`, `maxDuration` |
|
|
50
|
+
| per-vu-iterations | `vus`, `iterations`, `maxDuration` |
|
|
51
|
+
| constant-vus | `vus`, `duration` |
|
|
52
|
+
| ramping-vus | `startVUs`, `stages`, `gracefulRampDown` |
|
|
53
|
+
| constant-arrival-rate | `rate`, `timeUnit`, `duration`, `preAllocatedVUs`, `maxVUs` |
|
|
54
|
+
| ramping-arrival-rate | `startRate`, `timeUnit`, `stages`, `preAllocatedVUs`, `maxVUs` |
|
|
55
|
+
| externally-controlled | `maxVUs`, `duration` |
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Stages (Ramping)
|
|
60
|
+
|
|
61
|
+
Define load profile with time-based stages.
|
|
62
|
+
|
|
63
|
+
```javascript
|
|
64
|
+
export const options = {
|
|
65
|
+
stages: [
|
|
66
|
+
{ duration: '2m', target: 50 }, // Ramp up to 50 VUs over 2 min
|
|
67
|
+
{ duration: '5m', target: 50 }, // Stay at 50 VUs for 5 min
|
|
68
|
+
{ duration: '2m', target: 100 }, // Ramp to 100 VUs
|
|
69
|
+
{ duration: '5m', target: 100 }, // Stay at 100 VUs
|
|
70
|
+
{ duration: '2m', target: 0 }, // Ramp down to 0
|
|
71
|
+
],
|
|
72
|
+
};
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Time units: `s`, `m`, `h`.
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## Thresholds
|
|
80
|
+
|
|
81
|
+
Pass/fail criteria for the test run.
|
|
82
|
+
|
|
83
|
+
```javascript
|
|
84
|
+
export const options = {
|
|
85
|
+
thresholds: {
|
|
86
|
+
http_req_duration: ['p(95)<200', 'p(99)<500'],
|
|
87
|
+
http_req_failed: ['rate<0.01'],
|
|
88
|
+
checks: ['rate>0.95'],
|
|
89
|
+
'http_req_duration{name:api}': ['p(95)<300'],
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Percentile Syntax
|
|
95
|
+
- `p(50)` — Median
|
|
96
|
+
- `p(90)` — 90th percentile
|
|
97
|
+
- `p(95)` — 95th percentile
|
|
98
|
+
- `p(99)` — 99th percentile
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## Output Formats
|
|
103
|
+
|
|
104
|
+
### JSON
|
|
105
|
+
```bash
|
|
106
|
+
k6 run --out json=results.json script.js
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### CSV
|
|
110
|
+
```bash
|
|
111
|
+
k6 run --out csv=results.csv script.js
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### InfluxDB
|
|
115
|
+
```bash
|
|
116
|
+
k6 run --out influxdb=http://localhost:8086/k6 script.js
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Prometheus (via k6 Prometheus extension)
|
|
120
|
+
```bash
|
|
121
|
+
k6 run --out experimental-prometheus script.js
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Cloud (k6 Cloud)
|
|
125
|
+
```bash
|
|
126
|
+
k6 cloud script.js
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Summary
|
|
130
|
+
Built-in summary prints to stdout. Customize with:
|
|
131
|
+
```javascript
|
|
132
|
+
import { htmlReport } from 'https://raw.githubusercontent.com/benc-uk/k6-reporter/main/dist/bundle.js';
|
|
133
|
+
|
|
134
|
+
export function handleSummary(data) {
|
|
135
|
+
return {
|
|
136
|
+
'summary.html': htmlReport(data),
|
|
137
|
+
stdout: textSummary(data, { indent: ' ', enableColors: true }),
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## Environment and Variables
|
|
145
|
+
|
|
146
|
+
### Environment Variables
|
|
147
|
+
```javascript
|
|
148
|
+
const baseUrl = __ENV.BASE_URL || 'https://example.com';
|
|
149
|
+
const apiKey = __ENV.API_KEY;
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Options Override via Env
|
|
153
|
+
```bash
|
|
154
|
+
BASE_URL=https://staging.example.com k6 run script.js
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Options Override via CLI
|
|
158
|
+
```bash
|
|
159
|
+
k6 run -e BASE_URL=https://staging.example.com script.js
|
|
160
|
+
k6 run --vus 20 --duration 1m script.js
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## Tags
|
|
166
|
+
|
|
167
|
+
Add tags for filtering metrics and organizing output.
|
|
168
|
+
|
|
169
|
+
```javascript
|
|
170
|
+
import http from 'k6/http';
|
|
171
|
+
|
|
172
|
+
export default function () {
|
|
173
|
+
const res = http.get('https://api.example.com/items', {
|
|
174
|
+
tags: { name: 'list_items', endpoint: 'GET /items' },
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
```javascript
|
|
180
|
+
export const options = {
|
|
181
|
+
tags: {
|
|
182
|
+
project: 'my-project',
|
|
183
|
+
env: 'staging',
|
|
184
|
+
},
|
|
185
|
+
};
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## TLS and Security
|
|
191
|
+
|
|
192
|
+
```javascript
|
|
193
|
+
export const options = {
|
|
194
|
+
insecureSkipTLSVerify: true, // For dev/staging only
|
|
195
|
+
tlsVersion: {
|
|
196
|
+
min: 'tls1.2',
|
|
197
|
+
max: 'tls1.3',
|
|
198
|
+
},
|
|
199
|
+
};
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
## Graceful Stop
|
|
205
|
+
|
|
206
|
+
Allow in-flight requests to complete before stopping VUs.
|
|
207
|
+
|
|
208
|
+
```javascript
|
|
209
|
+
export const options = {
|
|
210
|
+
scenarios: {
|
|
211
|
+
main: {
|
|
212
|
+
executor: 'constant-vus',
|
|
213
|
+
vus: 10,
|
|
214
|
+
duration: '5m',
|
|
215
|
+
gracefulStop: '30s',
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
};
|
|
219
|
+
```
|