chore(test): fixed teardown() causing tests to fail due to fs errors on removal

This commit is contained in:
Lam Wei Li 2022-01-19 09:24:55 +08:00
parent 43a2199137
commit a0baec23a8
No known key found for this signature in database
GPG Key ID: 90F6ABECF080D7BF
2 changed files with 16 additions and 5 deletions

View File

@ -236,8 +236,14 @@ test("multiFile appender", batch => {
});
});
batch.tearDown(() => {
fs.rmdirSync("logs");
batch.tearDown(async () => {
try {
const files = fs.readdirSync("logs");
await removeFiles(files.map(filename => `logs/${filename}`));
fs.rmdirSync("logs");
} catch (e) {
// doesn't matter
}
});
batch.end();

View File

@ -77,11 +77,16 @@ tap.test("Drain event test", batch => {
logger.info("This is a test for emitting drain event in date file logger");
}
t.end();
});
batch.tearDown(() => {
fs.rmdirSync("logs");
batch.tearDown(async () => {
try {
const files = fs.readdirSync("logs");
await removeFiles(files.map(filename => `logs/${filename}`));
fs.rmdirSync("logs");
} catch (e) {
// doesn't matter
}
});
batch.end();