Skip to content

Simple Load Testing

The framework ships with a lightweight CLI helper for stress testing HTTP endpoints without leaving your project.

Run scripts via npm:

bash
npm run load:test -- --url http://localhost:3000/health

Options

FlagDescriptionDefault
--urlTarget endpoint (required)
--requestsTotal requests to send when duration is not set50
--durationDuration in seconds to run continuously; overrides --requests when provided
--concurrencyNumber of concurrent workers issuing requests5
--methodHTTP methodGET
--bodyRaw request body string
--headerRepeatable header flag (--header "Header: value")

Usage Patterns

Fixed Request Count

bash
npm run load:test -- --url http://localhost:3000/api/users --requests 500 --concurrency 20

Use this mode for fast feedback on latency distributions and status ratios after a code change.

Fixed Duration

bash
npm run load:test -- --url http://localhost:3000/api/users --duration 30 --concurrency 12

Great for soak-style checks; the script stops automatically after the requested number of seconds.

Custom Payloads

bash
npm run load:test -- \
  --url http://localhost:3000/api/users \
  --method POST \
  --body '{"name":"Test","email":"test@example.com"}' \
  --header 'Content-Type: application/json'

Repeat the --header flag to add authorization tokens or correlation IDs as needed. Consider storing sensitive values in environment variables instead of shell history when sharing credentials.

Output

Each run prints latency min/avg/p50/p95/max, the number of successes and failures, and a histogram of HTTP status codes. The script also lists up to five failure examples to help you debug quickly.

Tips

  • Keep concurrency reasonable when pointing at shared environments to avoid interrupting teammates.
  • Pair runs with your existing observability stack (e.g. Grafana dashboards) to correlate latency spikes with resource usage.
  • Commit useful command invocations to project docs or scripts so future contributors can repeat them quickly.

Released under the ISC License.