
k6 Has a Free API — Load Testing for Developers Who Write JavaScript
k6 is a load testing tool where you write tests in JavaScript. Built by Grafana Labs, it's fast (Go runtime), scriptable (JS API), and integrates with your CI/CD pipeline. Why k6? JavaScript tests — write tests in JS, run in Go (fast!) Developer-first — version control your tests, run in CI Built-in metrics — response time, throughput, error rate Extensions — Redis, SQL, Kafka, browser testing Quick Start # Install brew install k6 # macOS apt install k6 # Ubuntu # Or Docker docker run -i grafana/k6 run - <script.js Basic Test // test.js import http from ' k6/http ' ; import { check , sleep } from ' k6 ' ; export const options = { vus : 10 , // 10 virtual users duration : ' 30s ' , // for 30 seconds }; export default function () { const res = http . get ( ' https://api.example.com/users ' ); check ( res , { ' status is 200 ' : ( r ) => r . status === 200 , ' response time < 500ms ' : ( r ) => r . timings . duration < 500 , ' body has users ' : ( r ) => JSON . parse ( r . body ). length
Continue reading on Dev.to Tutorial
Opens in a new tab



