Skip to content

Node.js based forum software built for the modern web

test: have some build tests not pollute build folder

Julian Lam7c5a915dc9b1
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,