Mocha Dynamic Tests
If you want to test your code against a bunch of slightly different inputs,
writing a bunch of Mocha it
statements becomes tedious.
Instead, you can use this package to define your tests as an array of
plain JavaScript objects and pass those to Mocha's it
.
Mocha naturally supports dynamic tests (also known as parameterized tests). However, this package eliminates some of the cruft involved in writing dynamic tests that also support.
How to use
Here's an example of how to use it:
var dynamicTests = var { return value}
API
dynamicTests
accepts three arguments:
- array of test objects
- function that returns the test details
Test objects array
The array of tests is an array of objects.
Test details function
This function must return an object that contains description
and body
properties that
will be passed to Mocha's it
as such it(test.description, test.body)
.
Therefore, description
must be a string, and body
must be a function.