Skip to content

Commit 86d4bf0

Browse files
authored
test: refactor cli test (#3024)
1 parent 7d339d4 commit 86d4bf0

File tree

2 files changed

+5
-30
lines changed

2 files changed

+5
-30
lines changed

test/cli/cli.test.js

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,9 @@ const path = require('path');
44
const execa = require('execa');
55
const internalIp = require('internal-ip');
66
const testBin = require('../helpers/test-bin');
7-
const isWebpack5 = require('../helpers/isWebpack5');
87

98
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'
9+
it('--hot', (done) => {
3510
testBin('--hot --stats=detailed')
3611
.then((output) => {
3712
expect(output.exitCode).toEqual(0);
@@ -41,8 +16,8 @@ describe('CLI', () => {
4116
.catch(done);
4217
});
4318

44-
webpack5Test('--no-hot webpack 5', (done) => {
45-
testBin('--no-hot --stats=detailed')
19+
it('--no-hot', (done) => {
20+
testBin('--no-hot')
4621
.then((output) => {
4722
expect(output.exitCode).toEqual(0);
4823
expect(output.stdout).not.toContain('webpack/hot/dev-server.js');
@@ -52,8 +27,7 @@ describe('CLI', () => {
5227
});
5328

5429
it('--hot-only', (done) => {
55-
// need detailed stats to check for 'only-dev-server.js'
56-
testBin('--hot-only --stats detailed')
30+
testBin('--hot-only')
5731
.then((output) => {
5832
expect(output.exitCode).toEqual(0);
5933
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)