How to write parametrized tests with Jasmine unit testing framework (or any other other BDD JavaScript testing framework)?
AFAIK Jasmine doesn't have parametrized tests support. So I came up with this simple approach:
describe('Testing module', function() {
var testCases = [
{ param1: 'testcase1Param1', param2: 'testCase1Param2'},
{ param1: 'testcase2Param1', param2: 'testCase2Param2'},
];
/*jshint -W083 */ //Disable warning for function created inside loop
//this is parametrized test and it's better readable this way.
testCases.forEach(function(testCase) {
describe('for test case: param1" ' + testCase.param1 +
' and param2: "' + testCase.param2 + '"', function() {
//do your testing
}
}
});