
Grafana k6 Has a Free API That Load Tests Your APIs With JavaScript
k6 is a load testing tool that uses JavaScript for test scripts. Run locally, in CI/CD, or in the cloud. Write tests like you write code — not XML configs. Quick Start # Install brew install k6 # macOS sudo apt install k6 # Ubuntu # Run a test k6 run script.js Basic Load Test import http from ' k6/http ' import { check , sleep } from ' k6 ' export const options = { vus : 50 , // 50 virtual users duration : ' 30s ' , // for 30 seconds } export default function () { const res = http . get ( ' https://api.example.com/posts ' ) check ( res , { ' status is 200 ' : ( r ) => r . status === 200 , ' response time < 500ms ' : ( r ) => r . timings . duration < 500 , }) sleep ( 1 ) } Ramping (Realistic Traffic Patterns) export const options = { stages : [ { duration : ' 2m ' , target : 100 }, // ramp up to 100 users { duration : ' 5m ' , target : 100 }, // stay at 100 { duration : ' 2m ' , target : 200 }, // spike to 200 { duration : ' 5m ' , target : 200 }, // stay at 200 { duration : ' 2m ' , ta
Continue reading on Dev.to JavaScript
Opens in a new tab

