I'm probabbly doing a bad thing here, because I'm having dependencies between tests, but I'd rather call it initialization.
Here's what I have:
describe('e2e', function () {
this.timeout(30000);
let domainWork = [];
it('should prepare material', function (done) {
glob("test/e2e/*", function (err, domains) {
Promise.all(domains.map(function (domain) {
console.log('new domain ' + domain);
let rqUrl = extractDomainUrl(domain);
constructPairs(domain)
.then(function (pairs) {
let work = {
domain: domain,
work: pairs,
rqUrl: rqUrl
};
domainWork.push(work);
Promise.resolve();
})
}))
.then(function () {
done();
});
});
});
it('should test domains', async function () {
return Promise.all(domainWork.map(function (domain) {
it('domain ' + domain.url, async function () {
return Promise.all(domain.work.map(function (casse) {
it('testCase ' + casse.caseNum, async function () {
chai.request(server)
.post(rqUrl)
.send(casse.req)
.end(async (err, res) => {
expect(err).to.be.null;
let comparison = compareJSON(casse.res, res.body);
if (comparison)
return Promise.resolve();
else
return Promise.reject();
});
})
}))
})
}))
});
});
So what I need to do is to initialize an array domainWork and then run tests with for this data in the loop. I have read somewher in this forum, that you can run tests in the loop. So I have 'prepare material'-it I have second one 'should test domains'-it which should serve as describing for upcoming operations and encapsulate loop through "test domains" (domainWork array).
Now, what happens when I run this, is that first test initializes 'domainWork' array. Then it gets to the second test, but the inner most test/it is never being executed.
What I need to do in odrer to execute the inner test? Or what would be the better solution to rewrite this?
Thanks!
Aucun commentaire:
Enregistrer un commentaire