adding cleanup to tests

This commit is contained in:
Daniël 2024-06-04 18:52:32 +02:00
parent 4cbc4c2d31
commit a0ae2274f9

View file

@ -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,