Elegant load testing, on Bun
installation • usage • examples • configuration
bun add @meistrari/bolt
bolt allows you to easily set up and run performance tests.
import { createBoltRunner, defineImplementation } from '@meistrari/bolt'
// define your test implementation
defineImplementation(async ({ url }) => {
const res = await fetch(url)
if (!res.ok)
throw new Error(`http error! status: ${res.status}`)
return res.json()
})
// create and run your tests
const runner = createBoltRunner('your-test-file.ts')
await runner([
{
name: 'get posts',
iterations: 100,
concurrency: 10,
data: { url: 'https://api.example.com/posts' },
},
])
test implementation (http-api-test.ts
):
import { defineImplementation } from '@meistrari/bolt'
defineImplementation(async ({ url }) => {
const res = await fetch(url)
if (!res.ok)
throw new Error(`http error! status: ${res.status}`)
return res.json()
})
running tests (http-api.ts
):
import { createBoltRunner } from '@meistrari/bolt'
const runner = createBoltRunner('http-api-test.ts')
await runner([
{
name: 'entity list',
iterations: 2,
concurrency: 2,
data: { url: 'https://jsonplaceholder.typicode.com/posts' },
},
{
name: 'single entity',
iterations: 10,
concurrency: 10,
data: { url: 'https://jsonplaceholder.typicode.com/posts/1' },
},
])
bolt tests are configured using scenario objects:
{
name: string // name of the test scenario
iterations: number // number of times to run the test
concurrency: number // number of concurrent requests
data: any // data to pass to the test implementation
}
for more advanced configuration options, please refer to the documentation.
made with ❤️ by meistrari