Jasmine - Create multiple tests case with a set of data
The snippet below will allows you to easily create multiple jasmine tests with the same code base.
It'll be helpful because if a tests fails, you won't have to debug a long time before finding the failed case
describe('Global description', function () {
// Represent a set testable of data
_.each([1,2,3,5,7,9,11,13,17,23 /*, etc.*/], function(v) {
testingValues(v);
});
function testingValues(v) {
beforeEach(function () {
// Do something
});
describe('when returning content [v = ' + v + ']', function () {
it('should be true', function () {
// Arrange
// Act
// Assert
expect(v > 0).toBeTruthy();
});
});
}
});
Written by Jerome Freyre
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Javscript
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#