I learned that this way is the best way to loop through the it() in a describe(), but it failed on me with "spec not found", and seems stop right before the for loop function, I wonder where did I do wrong?
Thanks!
describe('this is my looping test!', function() {
var input = [1,2,3];
var output = [10, 20, 30];
function test_my_times_ten(input, output) {
it('should multiply ' + input + ' by 10 to give ' + output, function() {
expect(input * 10).toEqual(output)
});
}
for(var x = 0; x < input.size; x++) {
test_my_times_ten(input[x], output[x]);
}
});
Actually someone did really smart thing like this, and it seems does the work!
Looping on a protractor test with parameters
var testParams = testConfig.testArray;
for (var i = 0; i < testParams.length; i++) {
(function (testSpec) {
it('write your test here', function () {
//test code here
});
})(testParams[i]);
};
i think the real problem is "input.size" at line "for(var x = 0; x < input.size; x++) {" . there is no such thing called "input.size". try input.length and your test will run as expected
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With