explosives
v0.1.1
Published
Controlled fault-injection and chaos testing toolkit for Node.js services.
Readme
explosives
Controlled fault-injection and chaos testing toolkit for Node.js services.
Features
- Define named failure scenarios (delays, errors, drops) and scope them by environment.
- Runtime triggers, probabilistic injection, and scheduled blasts for integration and staging tests.
- Integrations for Express middleware, test-harness hooks, and a CLI runner for CI.
- Safe-by-default operation with dry-run mode and environment restrictions.
Install
npm install explosives
Quick Start
const Explosives = require('explosives');
const ex = new Explosives({ env: process.env.NODE_ENV || 'development' });
// register a scenario
ex.scenario('slow-db', {
type: 'delay', // delay, error, drop, or custom
target: 'db.query', // logical target name
delayMs: 2000,
probability: 0.5,
environments: ['staging', 'test']
});
// apply injection at a call site
async function query(sql) {
await ex.applyIf('slow-db'); // only injects when scenario matches
return db.query(sql);
}
// Express middleware integration (injects based on request metadata)
const express = require('express');
const app = express();
app.use(ex.expressMiddleware());
// CLI usage for scheduled blasts: `explosives blast --scenario slow-db --once`License
MIT
