@meistrari/bolt
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

bolt

Elegant load testing, on Bun

installationusageexamplesconfiguration

installation

bun add @meistrari/bolt

usage

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' },
    },
])

examples

http api test

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' },
    },
])

configuration

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

Dependencies (2)

Dev Dependencies (4)

Package Sidebar

Install

npm i @meistrari/bolt

Weekly Downloads

1

Version

0.0.2

License

MIT

Unpacked Size

9.21 kB

Total Files

5

Last publish

Collaborators

  • 0xthierry
  • rjmunhoz
  • henrykunh