challenge
v1.0.7
Published
A node.js mocha unit test generator with support for JSON case data.
Downloads
45
Readme
challenge
============
A node.js unit test generator with support for JSON case data
Examples:
Dynamically generate tests within a Mocha test suite using a JSON array:
Challenge
.cases(['first', 'second'])
.test('should generate two tests',
function(pCase, fDone)
{
Expect(pCase)
.to.be.a('string');
return fDone();
});
Or, load JSON data from a file and generate tests for each selected element in an array:
Challenge
.cases({loadFrom:'case-data.json', range: [0,1]})
.test('should generate tests from json data',
function(pCase, fDone)
{
Expect(pCase)
.to.have.property('name');
Expect(pCase.id.toString())
.to.equal(pCase.name[pCase.name.length-1]); //id should match last letter of 'name'
return fDone();
});
See the unit test for more complex examples, including joining and grouping test case data to generate tests.