-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
cli.test.js
49 lines (41 loc) · 1.4 KB
/
cli.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
'use strict';
const assert = require('assert');
const path = require('path');
const execa = require('execa');
const semver = require('semver');
const pkg = require('../package.json');
const runDevServer = require('./helpers/run-webpack-dev-server');
describe('CLI Dependencies', () => {
it('should lock down certain dependencies', () => {
const yargs = pkg.dependencies.yargs;
// yargs needs to be locked down to 9.0.1, since that is what webpack-cli is also doing
assert(semver.satisfies(yargs, '9.0.1'));
});
});
describe('CLI', () => {
it('--progress', (done) => {
runDevServer('--progress')
.then((output) => {
assert(output.code === 0);
assert(output.stderr.indexOf('0% compiling') >= 0);
done();
})
.catch(done);
}).timeout(6000);
it('should exit the process when SIGINT is detected', (done) => {
const cliPath = path.resolve(__dirname, '../bin/webpack-dev-server.js');
const examplePath = path.resolve(__dirname, '../examples/cli/public');
const nodePath = execa.shellSync('which node').stdout;
const proc = execa(nodePath, [cliPath], { cwd: examplePath });
proc.stdout.on('data', (data) => {
const bits = data.toString();
if (/Compiled successfully/.test(bits)) {
assert(proc.pid !== 0);
proc.kill('SIGINT');
}
});
proc.on('exit', () => {
done();
});
}).timeout(6000);
});