From b5f320e0fdfc871dc78f0b3eac89904774fa5b03 Mon Sep 17 00:00:00 2001 From: abetomo Date: Tue, 26 May 2020 09:19:32 +0900 Subject: [PATCH] test(improvement): Add tearDown to unit tests This leaves the following Untracked files. `test/tap/freeze-date-file-test` --- test/tap/configuration-validation-test.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/test/tap/configuration-validation-test.js b/test/tap/configuration-validation-test.js index fb965b3b..915e9968 100644 --- a/test/tap/configuration-validation-test.js +++ b/test/tap/configuration-validation-test.js @@ -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 } },