Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/twipped/nodeunit-dataprovider
Helper function for nodeunit to generate sets of tests using arrays of test data.
https://github.com/twipped/nodeunit-dataprovider
Last synced: about 1 month ago
JSON representation
Helper function for nodeunit to generate sets of tests using arrays of test data.
- Host: GitHub
- URL: https://github.com/twipped/nodeunit-dataprovider
- Owner: Twipped
- License: mit
- Created: 2014-03-14T19:38:27.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2018-01-05T18:30:25.000Z (almost 7 years ago)
- Last Synced: 2024-08-09T11:16:34.406Z (5 months ago)
- Language: JavaScript
- Size: 18.6 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
nodeunit-dataprovider
===A quick solution for generating sets of repeating tests using an array of input data.
##Node.js
To install:
npm install nodeunit-dataprovider
To use:
```js
var dataprovider = require('nodeunit-dataprovider');
```##Example:
```js
var dataprovider = require('nodeunit-dataprovider');exports['doubled result'] = dataprovider(
[
{input: 4, output: 8},
{input: 8, output: 16},
{input: 16, output: 32}
],
function (test, data) {
test.strictEqual(data.input * 2, data.output);
test.done();
}
);exports['doubled result with named doubles'] = dataprovider(
{
Set1: {input: 4, output: 8},
Set2: {input: 8, output: 16},
Set3: {input: 16, output: 32}
},function (test, data, index) {
test.strictEqual(data.input * 2, data.output);
test.done();
}
);
``````
$ nodeunit test.jstest.js
✔ doubled result - #0: {"input":4,"output": ...
✔ doubled result - #1: {"input":8,"output": ...
✔ doubled result - #2: {"input":16,"output" ...
✔ doubled result with named doubles - #0: Set1
✔ doubled result with named doubles - #1: Set2
✔ doubled result with named doubles - #2: Set3OK: 6 assertions (14ms)
```