This question already has an answer here:
I'm having trouble returning a value (for the entire exported function not just one particular test) when all the unit tests in a file finishes. I'm currently using es6 javascript code and exporting my tests inside a function object. I'm hoping to use the "chainLink" as a resolvable promise
It should return "true" or some value after all the tests are done running so that I can later fire a callback.
Code Sample
export function chainLink(url, jsonUrl) {
test.before(async t => {
document = await loadedDocument(url);
json = await loadedJson(jsonUrl);
});
test('body should not be empty', t => {
const body = document.querySelector('body');
t.true(body.innerHTML.length > 0);
});
test('article type is rendered', t => {
const article = document.getElementsByTagName('article');
t.true(article.length > 0);
});
// first attempt at returning a value // doesn't work
test.after('finish stuff', t => {
return;
});
};
A lot of unit testing framework include a ".after()" method that runs after all the other tests have finished. Placing a "return" or "return true" inside the ".after()" method doesn't result in any value returned.
Is it possible?
Aucun commentaire:
Enregistrer un commentaire