From b9cc14551d9fc3e6b317af8644a6c112bdd37b36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20Edstr=C3=B6m?= Date: Wed, 4 May 2022 14:38:52 +0200 Subject: [PATCH] Re-introduce accidentally removed test --- test/cache.test.js | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/test/cache.test.js b/test/cache.test.js index 6f3c8ee2..ac6ffb16 100644 --- a/test/cache.test.js +++ b/test/cache.test.js @@ -156,6 +156,45 @@ test.serial.cb( }, ); +test.serial.cb( + "should output files to standard cache dir if set to true in query", + t => { + const config = Object.assign({}, globalConfig, { + output: { + path: t.context.directory, + }, + module: { + rules: [ + { + test: /\.jsx?/, + loader: babelLoader, + exclude: /node_modules/, + options: { + cacheDirectory: true, + presets: ["@babel/preset-env"], + }, + }, + ], + }, + }); + + webpack(config, (err, stats) => { + t.is(err, null); + t.deepEqual(stats.compilation.errors, []); + t.deepEqual(stats.compilation.warnings, []); + + fs.readdir(defaultCacheDir, (err, files) => { + files = files.filter(file => /\b[0-9a-f]{5,40}\.json\.gz\b/.test(file)); + + t.is(err, null); + + t.true(files.length > 0); + t.end(); + }); + }); + }, +); + test.cb("should read from cache directory if cached file exists", t => { const config = Object.assign({}, globalConfig, { output: {