-
-
Notifications
You must be signed in to change notification settings - Fork 384
/
Copy pathTestMemoryFS.test.js
51 lines (41 loc) · 1.29 KB
/
TestMemoryFS.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import path from 'path';
import { createFsFromVolume, Volume } from 'memfs';
import webpack from 'webpack';
const assetsNames = (json) => json.assets.map((asset) => asset.name);
describe('TestMemoryFS', () => {
it('should preserve asset even if not emitted', (done) => {
const casesDirectory = path.resolve(__dirname, 'cases');
const directoryForCase = path.resolve(casesDirectory, 'simple-publicpath');
// eslint-disable-next-line import/no-dynamic-require, global-require
const webpackConfig = require(path.resolve(
directoryForCase,
'webpack.config.js'
));
const compiler = webpack({
...webpackConfig,
mode: 'development',
context: directoryForCase,
cache: false,
});
const outputFileSystem = createFsFromVolume(new Volume());
// Todo remove when we drop webpack@4 support
outputFileSystem.join = path.join.bind(path);
compiler.outputFileSystem = outputFileSystem;
compiler.run((err1, stats1) => {
if (err1) {
done(err1);
return;
}
compiler.run((err2, stats2) => {
if (err2) {
done(err2);
return;
}
expect(assetsNames(stats1.toJson())).toEqual(
assetsNames(stats2.toJson())
);
done();
});
});
});
});