From a0ae2274f9dded3c7a05bd72136b504572e50a18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl?= <15849319+abcdan@users.noreply.github.com> Date: Tue, 4 Jun 2024 18:52:32 +0200 Subject: [PATCH] adding cleanup to tests --- tests/local.test.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/local.test.js b/tests/local.test.js index 6532147..cf1ccdb 100644 --- a/tests/local.test.js +++ b/tests/local.test.js @@ -15,6 +15,18 @@ if (!fs.existsSync(uploadPath)) { fs.mkdirSync(uploadPath); } +/** + * Ensure we clean up the uploads directory after each test + */ +afterEach(() => { + const files = fs.readdirSync(uploadPath); + files.forEach((file) => { + if (file !== "test.txt" && file !== ".gitkeep") { + fs.unlinkSync(path.join(uploadPath, file)); + } + }); +}); + const storageEngine = initializeLocalStorage( multerOptions, fileNameLength,