mocha-pipe
v0.0.7
Published
Build a test pipeline with mocha
Downloads
17
Maintainers
Readme
mocha-pipe
Build a test pipeline with mocha
mocha-pipe
mocha-pipe allows you to define your tests as a series of asynchronous units of work. Collectively the individual steps make up the pipeline. Each step pipes its output into the next step. If any uncaught exception occurs, the pipe is considered broken, and the step which threw the error will show as broken. The pipe returns a promise which will be resolved with the result from the last step.
Install
npm install --save-dev mocha-pipe
# or
yarn add -D mocha-pipe
Basic Example
const mochaPipe = require('mocha-pipe');
const steps = [{
name: 'Get user', // passed to it(name, ...);
before: () => 'MOCHA_PIPE',
execute: (username) => getUser(username),
after: res => assertSomething(res)
}, {
name: 'Update user email',
execute: user => updateEmail(user, '[email protected]'),
after: res => assertSomething(res)
}, {
name: 'Expect 401 on invalid password',
execute: user => authenticate(user, 'bad password').catch(err => assertStatusCode(err, '401'))
}];
const pipeline = mochaPipe({
name: 'Basic Example', // passed to describe(name, ...);
steps
});
pipeline.run();