Script Editor
Code-based test creation using JavaScript and the k6 framework. Write custom logic, advanced scenarios, and leverage the complete k6 API.
![]() |
|---|
k6 Script Structure
import http from 'k6/http'
import { check, sleep } from 'k6'
export const options = {
vus: 10,
duration: '30s',
thresholds: {
'http_req_duration': ['p(95)<500'],
},
}
export default function () {
const res = http.get('https://api.example.com/users')
check(res, {
'status is 200': (r) => r.status === 200,
})
sleep(1)
}
Key components:
- Imports - k6 modules and libraries
- Options - Load pattern, duration, and thresholds
- Default function - Test logic executed by each VU
- Setup/Teardown - Optional lifecycle hooks
Templates
Start from pre-built templates for common scenarios.
![]() |
|---|
Available templates include basic HTTP tests, authentication flows, CRUD operations, multi-step journeys, stress tests, and spike tests.
Importing Scripts
Load existing k6 scripts from files or URLs.
![]() |
|---|
![]() |
|---|
Click Import and select source (file or URL).
AI Script Generation
Generate complete k6 scripts from natural language descriptions.
![]() |
|---|
![]() |
|---|
Click the AI icon, describe your test scenario, and review the generated script.
Code Validation
Real-time syntax validation with error highlighting.
![]() |
|---|
Syntax errors, missing imports, and invalid k6 API usage are flagged inline.
k6 Documentation
For comprehensive k6 scripting capabilities:
- k6 JavaScript API: https://k6.io/docs/javascript-api/
- HTTP Requests: https://k6.io/docs/javascript-api/k6-http/
- Checks & Thresholds: https://k6.io/docs/using-k6/checks/
- Metrics: https://k6.io/docs/using-k6/metrics/
Complex script logic (loops, conditionals, custom functions) may not fully translate to Test Builder's visual interface.
Next Steps
- Running Tests - Execute and monitor tests
- Analyzing Results - Review metrics and insights
- Test Builder - Visual test creation






