So, I have an async function, which fetches an array of objects, to which I want to do testing to. But the problem is, each tests refers to the same array, even if I fetch it individually before each test.
describe('Package parser mock status file tests', async () => {
let packages: Package[] = [];
beforeEach(async function () {
packages = await PackageParser.fromStatusFile("tests/mockStatusFile.txt");
});
afterEach(async function () {
packages.length = 0;
});
This causes the array being filled as many times as there are tests, even though I empty it before each test. Even if I set the arrays to a different variable in each test. I'm aware of object and array referencing and async to some extent, but I don't understand how this is possible.
I'm using Mocha.
Aucun commentaire:
Enregistrer un commentaire