0.0.5 • Published 4 years ago

mocha-waterfall v0.0.5

Weekly downloads
4
License
WTFPL
Repository
github
Last release
4 years ago

mocha-waterfall

Runs test files with mocha sequentially.

It solves a problem when several test files open same port, mocha tries to run them simultaneously, and one of them gets an error.

Usage

Create file runall.js:

const MochaWaterfall = require('mocha-waterfall');

const mochaWaterfall = new MochaWaterfall({
    filenames: ['test1.js', 'test2.js'],
    failOnStderr: true,
    flags: ['bail', 'exit'],
    maxRestarts: 1,
});

mochaWaterfall.execute();

Then run node runall.js

Usage with local mocha and npx

If you want to use locally installed mocha, you can specify execCommand option:

const mochaWaterfall = new MochaWaterfall({
    //...
    execCommand: 'npx mocha'

    // or specify relative path:
    // execCommand: '../node_modules/.bin/mocha'
});

Options

nametyperequiredmeaning
filenamesarray of stringsyestest files to execute
failOnStderrbooleanyeswhether to stop execution when a test file writes to stderr
bailbooleannowhether to run mocha with --bail flag; defaults to false
flagsarray of stringsnoflags to execute mocha with; e.g. ['bail', 'exit'] will result in executing mocha --bail --exit
maxRestartsnumbernohow many times to rerun failed test file; defaults to 0
execCommandstringnowhat command to use to start mocha