I'm trying to generate tests dynamically using a for-loop, but the number of tests to generate is obtained from a async task. Here is my code:
var noOfTestsToRun;
before(function() {
return someAsyncTask().then(function(result) {
noOfTestsToRun = result;
})
});
describe('My Test Suite', function() {
for (var i = 0; i < noOfTestsToRun; i++) {
it('Test ' + i, function() {
//...
});
}
});
However, noOfTestsToRun = result
doesn't seem to be executed when it reaches the for
loop.
I was wondering if there are any solutions to this kind of problems. Thank you.