Merge pull request #1022 from abetomo/feature/improve_unit_testing_teardown

test(improvement): Add tearDown to unit tests
This commit is contained in:
Lam Wei Li 2022-01-19 01:38:49 +08:00 committed by GitHub
commit c45bfeb4fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,5 @@
const { test } = require("tap");
const { unlinkSync } = require("fs");
const util = require("util");
const path = require("path");
const sandbox = require("@log4js-node/sandboxed-module");
@ -247,13 +248,21 @@ test("log4js configuration validation", batch => {
);
batch.test("should not throw error if configure object is freezed", t => {
const filename = "test/tap/freeze-date-file-test"
t.tearDown(() => {
try {
unlinkSync(filename);
} catch (_) {
// doesn't really matter if it failed
}
});
t.doesNotThrow(() =>
log4js.configure(
deepFreeze({
appenders: {
dateFile: {
filename,
type: "dateFile",
filename: "test/tap/freeze-date-file-test",
alwaysIncludePattern: false
}
},