/
analyze-flag.test.js
30 lines (23 loc) · 1.13 KB
/
analyze-flag.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
'use strict';
const { run, runAndGetWatchProc } = require('../utils/test-utils');
describe('--analyze flag', () => {
it('should load webpack-bundle-analyzer plugin with --analyze flag', (done) => {
const proc = runAndGetWatchProc(__dirname, ['--analyze'], false, '', true);
proc.stdout.on('data', (chunk) => {
const data = chunk.toString();
if (data.includes('Webpack Bundle Analyzer is started at')) {
expect(data).toContain('Webpack Bundle Analyzer is started at');
proc.kill();
done();
}
});
});
it('should not load webpack-bundle-analyzer plugin twice with --analyze flag and plugin', () => {
const { exitCode, stderr, stdout } = run(__dirname, ['-c', './analyze.config.js', '--analyze']);
expect(exitCode).toBe(0);
expect(stderr).toContain('Compilation starting...');
expect(stderr).toContain('Compilation finished');
expect(stdout).toContain('Webpack Bundle Analyzer saved report to');
expect(stdout.match(/Webpack Bundle Analyzer saved report to/g)).toHaveLength(1);
});
});