Create k6 Load Testing Suite
testing
JavaScript
testing
strict_senior
Generate comprehensive k6 load tests with multiple scenarios, authentication, and custom metrics.
By david_kim
12/8/2025
Prompt
Create a complete k6 load testing suite for [APPLICATION_NAME] with the following specifications:
Requirements
- Application name: [APPLICATION_NAME]
- Base API URL: [API_BASE_URL]
- Authentication method: [Bearer Token/API Key/Basic Auth/None]
- Test scenarios: [SCENARIO_1], [SCENARIO_2], [SCENARIO_3]
- Performance thresholds:
- p95 response time: [MILLISECONDS]ms
- Error rate: [PERCENTAGE]%
- Target VUs: [NUMBER_OF_VIRTUAL_USERS]
- Load profile: [Ramp-up/Constant/Spike/Stress Test]
- Test duration: [DURATION]
Deliverables
Generate complete k6 test scripts with:
Main test configuration with:
- Staged load profile: ramp-up, sustain, ramp-down durations and targets
- Performance thresholds for http_req_duration and http_req_failed
- Multiple execution scenarios with different VU patterns
Test scenarios for each [SCENARIO]:
- Exported scenario function
- HTTP requests to [ENDPOINTS]
- Response validation checks (status codes, response times, data validation)
- Realistic think time with sleep()
Authentication flow if [AUTH_METHOD] is not None:
- Login/token acquisition
- Token storage and reuse
- Authorization header injection
- Token refresh if needed
Custom metrics to track:
- Business-specific timing metrics using Trend
- Custom counters for business events
- Rate metrics for conversion tracking
Data generation for realistic test data:
- Parameterized test data
- Shared data arrays or CSV reading
- Randomized but valid request payloads
Output complete, executable k6 scripts ready to run locally or in k6 Cloud.
Tags
k6
load-testing
performance
testing
Tested Models
gpt-4
claude-3-5-sonnet