Registry / testing / bench-rest

bench-rest

JSON →
library1.2.4jsnpmunverified

bench-rest is a Node.js library (v1.2.4, no recent release) for load-testing REST APIs using a declarative DSL. It combines request, async, and measured to define REST flows with setup/teardown, token substitution, and concurrency control. Metrics include latency, throughput, and error counts. Last updated around 2016; works with Node >=0.10. Simpler than artillery but limited to HTTP(S); no WebSocket support.

npm install bench-rest
INSTALL
IMPORT
SIG · BENCH-REST
B
bench-rest
testingjavascriptv1.2.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

benchrest
const benchrest = require('bench-rest')
import benchrest from 'bench-rest'
Package is CJS-only, no ESM exports. Use require.
BenchrestFlow
const flow = require('./myflow')
No type exports; flow is a plain object/array.
EventEmitter
const emitter = benchrest(flow, runOptions)
benchrest(flow, runOptions, callback)
benchrest returns an EventEmitter; use .on('end', ...) not a callback.

Defines a simple GET flow, runs 100 iterations with 10 concurrent connections, and logs stats on completion.

const benchrest = require('bench-rest'); const flow = { main: [{ get: 'http://localhost:8000/api' }] }; const runOptions = { limit: 10, iterations: 100 }; benchrest(flow, runOptions) .on('error', (err, ctxName) => console.error('Error in %s:', ctxName, err)) .on('end', (stats, errorCount) => { console.log('Errors:', errorCount); console.log('Stats:', JSON.stringify(stats, null, 2)); });
Debug
Known issues
deprecatedThe 'request' dependency is deprecated; bench-rest still uses it internally and will emit deprecation warnings.
fix
Pin request to a specific version or suppress warnings. Consider migrating to a newer tool like artillery.
affects: >=1.0.0
breakingThe 'async' library used internally may cause issues with Node >=10 due to async/await conflicts.
fix
Use Node <10 or pin bench-rest to v1.2.0 and test thoroughly.
affects: >=1.2.0
gotchaToken substitution uses #{INDEX} but indices are 1-based; flow arrays are not deep-merged.
fix
Use #{INDEX} for iteration index (starts at 1). For custom tokens, ensure they are strings.
affects: >=1.0.0
gotchaCalling benchrest with a URL string as flow requires exactly one GET request; array/object flows require proper structure.
fix
Use an object with 'main' array for multi-step flows.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'bench-rest'
Package not installed.
fix
npm install bench-rest
benchrest is not a function
Using ES6 import style incorrectly.
fix
Use const benchrest = require('bench-rest')
TypeError: Cannot read property 'on' of undefined
Bypassing the EventEmitter pattern and expecting a callback.
fix
Attach listeners to the returned emitter: benchrest(flow, opts).on('end', ...)
Upgrade
Version history
1.2.4latest on npm
Audit
Dependencies
requestrequiredHTTP client used for all REST calls
asyncrequiredControls flow execution and concurrency
measuredrequiredProvides metrics and statistics collection
commanderrequiredUsed for CLI argument parsing
Agent activity
20 hits · last 30 days
node
16
Perplexity
1
OpenAI (training)
1
Resources