From 7c5a915dc9b1d25d40b35a05086012e2f392c122 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Tue, 23 Aug 2022 11:23:49 -0400 Subject: [PATCH] test: have some build tests not pollute build folder --- test/build.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/test/build.js b/test/build.js index 3386fa2e6f..52e828f856 100644 --- a/test/build.js +++ b/test/build.js @@ -9,11 +9,17 @@ const async = require('async'); const db = require('./mocks/databasemock'); const file = require('../src/file'); -const helpers = require('./helpers'); describe('minifier', () => { + const testPath = path.join(__dirname, '../test/build'); before(async () => { - await mkdirp(path.join(__dirname, '../build/test')); + await mkdirp(testPath); + }); + + after(async () => { + const files = await file.walk(testPath); + await Promise.all(files.map(async path => fs.promises.rm(path))); + await fs.promises.rmdir(testPath); }); const minifier = require('../src/meta/minifier'); @@ -22,12 +28,12 @@ describe('minifier', () => { path.resolve(__dirname, './files/2.js'), ].map(script => ({ srcPath: script, - destPath: path.resolve(__dirname, '../build/test', path.basename(script)), + destPath: path.resolve(__dirname, '../test/build', path.basename(script)), filename: path.basename(script), })); it('.js.bundle() should concat scripts', (done) => { - const destPath = path.resolve(__dirname, '../build/test/concatenated.js'); + const destPath = path.resolve(__dirname, '../test/build/concatenated.js'); minifier.js.bundle({ files: scripts, @@ -55,7 +61,7 @@ describe('minifier', () => { }); }); it('.js.bundle() should minify scripts', (done) => { - const destPath = path.resolve(__dirname, '../build/test/minified.js'); + const destPath = path.resolve(__dirname, '../test/build/minified.js'); minifier.js.bundle({ files: scripts,