Mocha Filter
This package allows you to add custom filters to the various test stages in the Mocha test framework.
By default (when you require('mocha-filter')
) an ignore
filter is added, which will completely remove a test (or set of tests) from the test run without leaving a trace in the test output.
Examples
The filters can be used to restrict test runs to only be used when in specific environments:
var filter = ; filter; describe;
So long as the supplied function for the filter returns true
, false
, or 'skip'
, you can make it execute whatever you would like, without having to wrap tests in conditionals
filter;
You can also add multiple filters at once by passing an object containing all the required funtions, with the key being the name of the filter:
var filter = ; var filters = { return true; } { return false; } filter;
Alternatively, you can pass in a default set of filters when requiring the package:
var filters = { return true; } { return false; } var filter = filters;