Skip to content

djorg83/mocha-pipe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mocha-pipe

Build a test pipeline with mocha

Build Status Coverage Status NPM version Downloads David devDependencies Status GitHub issues license GitHub stars Built with love Powered by mocha

Gittip

NPM

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, 'a@b.com'),
    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();

About

Build a test pipeline with mocha

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published