Something I've come across when trying to restructure my tests to be more modular (instead of having a super long list of tests in one file) is that the "test()" inside the exported file doesn't run after the "test.before()" in the file it was required from.
What should I do to make sure that the "test()" always run after "test.before()" regardless of which file they're being called in?
I have one main file that imports the tests:
import {otherTests} from './otherTests';
import {loadedDocument, loadedJson} from './asyncLoaders';
let document, json;
test.before(async t => {
document = await loadedDocument(url); // fetch stuff
json = await loadedJson(jsonUrl); // fetch stuff
});
// call tests from another file
otherTests(document, json);
File with tests to export:
export function otherTests(document, json) {
test('test document', t => {
t.true(document.length > 0);
});
test('test json', t => {
t.true(json.length > 0);
})
}
Could someone shed some light on what's happening and what's the correct way to do "export" tests from another file?
Solutions I've tried: --serial
Aucun commentaire:
Enregistrer un commentaire