Generate K6 Load Test Scripts and Analysis
K6 Load Testing Expert skill provides comprehensive load test script creation, performance testing methodologies, metrics analysis, and optimization strategies
Why it matters
Automate performance testing by generating robust K6 load test scripts. Analyze results to identify bottlenecks and ensure application scalability.
Outcomes
What it gets done
Create comprehensive K6 load test scripts using JavaScript.
Design realistic test scenarios including data-driven and session-based tests.
Analyze performance metrics and define pass/fail thresholds.
Implement advanced load testing patterns like spike and stress testing.
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/vb-k6-load-test | bash Overview
K6 Load Testing Expert
This skill provides expert guidance for K6 load testing, covering performance testing methodologies, test script design, metrics analysis, and optimization strategies. It helps you create comprehensive load test scripts using the K6 JavaScript API, design realistic test scenarios with virtual users and stages, and extract actionable insights from test results through custom metrics and thresholds. Use this skill when you need to validate API performance under load, design spike or stress tests to find system breaking points, implement data-driven testing with CSV files, create session-based user flows with authentication, or set up automated performance validation with thresholds. Use it when analyzing key performance indicators including response time, throughput, and error rates. Do NOT use this skill for browser-based load testing, or when you need simple uptime monitoring rather than comprehensive load testing.
What it does
This skill provides expert guidance for K6 load testing, covering performance testing methodologies, test script design, metrics analysis, and optimization strategies. It helps you create comprehensive load test scripts using the K6 JavaScript API, design realistic test scenarios with virtual users and stages, and extract actionable insights from test results through custom metrics and thresholds.
When to use - and when NOT to
Use this skill when you need to validate API performance under load, design spike or stress tests to find system breaking points, implement data-driven testing with CSV files, create session-based user flows with authentication, or set up automated performance validation with thresholds. Use it when analyzing key performance indicators including response time, throughput, and error rates.
Do NOT use this skill for browser-based load testing, or when you need simple uptime monitoring rather than comprehensive load testing.
Inputs and outputs
You provide your testing requirements: target endpoints, expected load patterns (VUs, duration, stages), authentication requirements, test data sources, and performance thresholds. The skill delivers complete K6 test scripts with proper structure, custom metrics configuration, realistic load patterns, data-driven test scenarios, and monitoring setup.
Here's a complete test script structure:
import http from 'k6/http';
import { check, sleep } from 'k6';
import { Rate, Trend } from 'k6/metrics';
const errorRate = new Rate('errors');
const customTrend = new Trend('custom_duration');
export const options = {
stages: [
{ duration: '2m', target: 10 },
{ duration: '5m', target: 10 },
{ duration: '2m', target: 20 },
{ duration: '5m', target: 20 },
{ duration: '2m', target: 0 },
],
thresholds: {
http_req_duration: ['p(95)<500'],
http_req_failed: ['rate<0.1'],
errors: ['rate<0.1'],
},
};
export function setup() {
return { token: getAuthToken() };
}
export default function(data) {
const params = {
headers: {
'Authorization': `Bearer ${data.token}`,
'Content-Type': 'application/json',
},
};
const response = http.get('https://api.example.com/users', params);
check(response, {
'status is 200': (r) => r.status === 200,
'response time < 500ms': (r) => r.timings.duration < 500,
});
errorRate.add(response.status !== 200);
customTrend.add(response.timings.duration);
sleep(1);
}
Integrations
The source material demonstrates command-line options for outputting results to InfluxDB, generating JSON output files, and using environment variables in scripts. K6 can import CSV files using papaparse with SharedArray for data-driven testing.
Who it's for
Performance engineers who need to validate API performance under realistic load conditions, QA teams implementing automated performance regression testing, DevOps engineers stress-testing infrastructure before production deployments, and backend developers optimizing API response times and throughput. The skill covers advanced patterns like spike testing, stress testing, session-based flows, and custom metrics that go beyond basic load testing tools.
FAQ
Common questions
Discussion
Questions & comments ยท 0
Sign In Sign in to leave a comment.