Skip to content

Commit a226f2f

Browse files
committed
test: refactor cli test
1 parent 7d339d4 commit a226f2f

File tree

2 files changed

+5
-29
lines changed

2 files changed

+5
-29
lines changed

test/cli/cli.test.js

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,7 @@ const testBin = require('../helpers/test-bin');
77
const isWebpack5 = require('../helpers/isWebpack5');
88

99
describe('CLI', () => {
10-
const webpack4Test = isWebpack5 ? it.skip : it;
11-
const webpack5Test = isWebpack5 ? it : it.skip;
12-
13-
webpack4Test('--hot webpack 4', (done) => {
14-
testBin('--hot')
15-
.then((output) => {
16-
expect(output.exitCode).toEqual(0);
17-
expect(output.stdout).toContain('webpack/hot/dev-server.js');
18-
done();
19-
})
20-
.catch(done);
21-
});
22-
23-
webpack4Test('--no-hot webpack 4', (done) => {
24-
testBin('--no-hot')
25-
.then((output) => {
26-
expect(output.exitCode).toEqual(0);
27-
expect(output.stdout).not.toContain('webpack/hot/dev-server.js');
28-
done();
29-
})
30-
.catch(done);
31-
});
32-
33-
webpack5Test('--hot webpack 5', (done) => {
34-
// need detailed stats to check for 'dev-server.js'
10+
it('--hot', (done) => {
3511
testBin('--hot --stats=detailed')
3612
.then((output) => {
3713
expect(output.exitCode).toEqual(0);
@@ -41,8 +17,8 @@ describe('CLI', () => {
4117
.catch(done);
4218
});
4319

44-
webpack5Test('--no-hot webpack 5', (done) => {
45-
testBin('--no-hot --stats=detailed')
20+
it('--no-hot', (done) => {
21+
testBin('--no-hot')
4622
.then((output) => {
4723
expect(output.exitCode).toEqual(0);
4824
expect(output.stdout).not.toContain('webpack/hot/dev-server.js');
@@ -52,8 +28,7 @@ describe('CLI', () => {
5228
});
5329

5430
it('--hot-only', (done) => {
55-
// need detailed stats to check for 'only-dev-server.js'
56-
testBin('--hot-only --stats detailed')
31+
testBin('--hot-only')
5732
.then((output) => {
5833
expect(output.exitCode).toEqual(0);
5934
expect(output.stdout).toContain('/hot/only-dev-server');

test/fixtures/cli/webpack.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
module.exports = {
44
mode: 'development',
5+
stats: 'detailed',
56
context: __dirname,
67
entry: './foo.js',
78
plugins: [

0 commit comments

Comments
 (0)