Skip to content

Commit af6c02b

Browse files
test: cleanup (#2688)
1 parent 60abcd4 commit af6c02b

File tree

52 files changed

+104
-122
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+104
-122
lines changed

test/build/basic/basic.test.js

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,147 +5,135 @@ const { run } = require('../../utils/test-utils');
55

66
describe('bundle command', () => {
77
it('should work without command (default command)', async () => {
8-
const { exitCode, stderr, stdout } = await run(__dirname, [], false);
8+
const { exitCode, stderr, stdout } = await run(__dirname, []);
99

1010
expect(exitCode).toBe(0);
1111
expect(stderr).toBeFalsy();
1212
expect(stdout).toBeTruthy();
1313
});
1414

1515
it('should work without command and options (default command)', async () => {
16-
const { exitCode, stderr, stdout } = await run(__dirname, ['--mode', 'development'], false);
16+
const { exitCode, stderr, stdout } = await run(__dirname, ['--mode', 'development']);
1717

1818
expect(exitCode).toBe(0);
1919
expect(stderr).toBeFalsy();
2020
expect(stdout).toBeTruthy();
2121
});
2222

2323
it('should work with multiple entries syntax without command (default command)', async () => {
24-
const { exitCode, stderr, stdout } = await run(__dirname, ['./src/index.js', './src/other.js'], false);
24+
const { exitCode, stderr, stdout } = await run(__dirname, ['./src/index.js', './src/other.js']);
2525

2626
expect(exitCode).toBe(0);
2727
expect(stderr).toBeFalsy();
2828
expect(stdout).toBeTruthy();
2929
});
3030

3131
it('should work with multiple entries syntax without command with options (default command)', async () => {
32-
const { exitCode, stderr, stdout } = await run(__dirname, ['./src/index.js', './src/other.js', '--mode', 'development'], false);
32+
const { exitCode, stderr, stdout } = await run(__dirname, ['./src/index.js', './src/other.js', '--mode', 'development']);
3333

3434
expect(exitCode).toBe(0);
3535
expect(stderr).toBeFalsy();
3636
expect(stdout).toBeTruthy();
3737
});
3838

3939
it('should work with multiple entries syntax without command with options #2 (default command)', async () => {
40-
const { exitCode, stderr, stdout } = await run(__dirname, ['--mode', 'development', './src/index.js', './src/other.js'], false);
40+
const { exitCode, stderr, stdout } = await run(__dirname, ['--mode', 'development', './src/index.js', './src/other.js']);
4141

4242
expect(exitCode).toBe(0);
4343
expect(stderr).toBeFalsy();
4444
expect(stdout).toBeTruthy();
4545
});
4646

4747
it('should work with multiple entries syntax without command with options #3 (default command)', async () => {
48-
const { exitCode, stderr, stdout } = await run(__dirname, ['./src/index.js', './src/other.js', '--entry', './src/again.js'], false);
48+
const { exitCode, stderr, stdout } = await run(__dirname, ['./src/index.js', './src/other.js', '--entry', './src/again.js']);
4949

5050
expect(exitCode).toBe(0);
5151
expect(stderr).toBeFalsy();
5252
expect(stdout).toBeTruthy();
5353
});
5454

5555
it('should work with and override entries from the configuration', async () => {
56-
const { exitCode, stderr, stdout } = await run(
57-
__dirname,
58-
['./src/index.js', './src/other.js', '--config', './entry.config.js'],
59-
false,
60-
);
56+
const { exitCode, stderr, stdout } = await run(__dirname, ['./src/index.js', './src/other.js', '--config', './entry.config.js']);
6157

6258
expect(exitCode).toBe(0);
6359
expect(stderr).toBeFalsy();
6460
expect(stdout).toBeTruthy();
6561
});
6662

6763
it('should work with the "build" alias', async () => {
68-
const { exitCode, stderr, stdout } = await run(__dirname, ['build'], false);
64+
const { exitCode, stderr, stdout } = await run(__dirname, ['build']);
6965

7066
expect(exitCode).toBe(0);
7167
expect(stderr).toBeFalsy();
7268
expect(stdout).toBeTruthy();
7369
});
7470

7571
it('should work with "bundle" alias', async () => {
76-
const { exitCode, stderr, stdout } = await run(__dirname, ['bundle'], false);
72+
const { exitCode, stderr, stdout } = await run(__dirname, ['bundle']);
7773

7874
expect(exitCode).toBe(0);
7975
expect(stderr).toBeFalsy();
8076
expect(stdout).toBeTruthy();
8177
});
8278

8379
it('should work with the "b" alias', async () => {
84-
const { exitCode, stderr, stdout } = await run(__dirname, ['b'], false);
80+
const { exitCode, stderr, stdout } = await run(__dirname, ['b']);
8581

8682
expect(exitCode).toBe(0);
8783
expect(stderr).toBeFalsy();
8884
expect(stdout).toBeTruthy();
8985
});
9086

9187
it('should work with entries syntax using the "build" alias', async () => {
92-
const { exitCode, stderr, stdout } = await run(__dirname, ['build', './src/index.js'], false);
88+
const { exitCode, stderr, stdout } = await run(__dirname, ['build', './src/index.js']);
9389

9490
expect(exitCode).toBe(0);
9591
expect(stderr).toBeFalsy();
9692
expect(stdout).toBeTruthy();
9793
});
9894

9995
it('should work with entries syntax using the "bundle" alias', async () => {
100-
const { exitCode, stderr, stdout } = await run(__dirname, ['bundle', './src/index.js'], false);
96+
const { exitCode, stderr, stdout } = await run(__dirname, ['bundle', './src/index.js']);
10197

10298
expect(exitCode).toBe(0);
10399
expect(stderr).toBeFalsy();
104100
expect(stdout).toBeTruthy();
105101
});
106102

107103
it('should work with entries syntax using the "b" alias', async () => {
108-
const { exitCode, stderr, stdout } = await run(__dirname, ['b', './src/index.js'], false);
104+
const { exitCode, stderr, stdout } = await run(__dirname, ['b', './src/index.js']);
109105

110106
expect(exitCode).toBe(0);
111107
expect(stderr).toBeFalsy();
112108
expect(stdout).toBeTruthy();
113109
});
114110

115111
it('should work with multiple entries syntax using the "build" alias', async () => {
116-
const { exitCode, stderr, stdout } = await run(__dirname, ['build', './src/index.js', './src/other.js'], false);
112+
const { exitCode, stderr, stdout } = await run(__dirname, ['build', './src/index.js', './src/other.js']);
117113

118114
expect(exitCode).toBe(0);
119115
expect(stderr).toBeFalsy();
120116
expect(stdout).toBeTruthy();
121117
});
122118

123119
it('should work with multiple entries syntax using the "build" alias and options', async () => {
124-
const { exitCode, stderr, stdout } = await run(
125-
__dirname,
126-
['build', './src/index.js', './src/other.js', '--mode', 'development'],
127-
false,
128-
);
120+
const { exitCode, stderr, stdout } = await run(__dirname, ['build', './src/index.js', './src/other.js', '--mode', 'development']);
129121

130122
expect(exitCode).toBe(0);
131123
expect(stderr).toBeFalsy();
132124
expect(stdout).toBeTruthy();
133125
});
134126

135127
it('should work with multiple entries syntax using the "build" alias and options', async () => {
136-
const { exitCode, stderr, stdout } = await run(
137-
__dirname,
138-
['build', '--mode', 'development', './src/index.js', './src/other.js'],
139-
false,
140-
);
128+
const { exitCode, stderr, stdout } = await run(__dirname, ['build', '--mode', 'development', './src/index.js', './src/other.js']);
141129

142130
expect(exitCode).toBe(0);
143131
expect(stderr).toBeFalsy();
144132
expect(stdout).toBeTruthy();
145133
});
146134

147135
it('should log error and suggest right name on the "buil" command', async () => {
148-
const { exitCode, stderr, stdout } = await run(__dirname, ['buil'], false);
136+
const { exitCode, stderr, stdout } = await run(__dirname, ['buil']);
149137

150138
expect(exitCode).toBe(2);
151139
expect(stderr).toContain("Unknown command or entry 'buil'");

test/build/build-variable/build-variable.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const { run } = require('../../utils/test-utils');
44

55
describe('bundle variable', () => {
66
it('compiles without flags and export variable', async () => {
7-
const { exitCode, stderr, stdout } = await run(__dirname, [], false);
7+
const { exitCode, stderr, stdout } = await run(__dirname, []);
88

99
expect(exitCode).toBe(0);
1010
expect(stderr).toBeFalsy();

test/build/bundle-variable/bundle-variable.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const { run } = require('../../utils/test-utils');
44

55
describe('bundle variable', () => {
66
it('compiles without flags and export variable', async () => {
7-
const { exitCode, stderr, stdout } = await run(__dirname, [], false);
7+
const { exitCode, stderr, stdout } = await run(__dirname, []);
88

99
expect(exitCode).toBe(0);
1010
expect(stderr).toBeFalsy();

test/build/config-format/commonjs-default/commonjs-default.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const { run } = require('../../../utils/test-utils');
22

33
describe('webpack cli', () => {
44
it('should support CommonJS file', async () => {
5-
const { exitCode, stderr, stdout } = await run(__dirname, ['-c', 'webpack.config.cjs'], false);
5+
const { exitCode, stderr, stdout } = await run(__dirname, ['-c', 'webpack.config.cjs']);
66

77
expect(exitCode).toBe(0);
88
expect(stderr).toBeFalsy();

test/build/config-format/commonjs/commonjs.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const { run } = require('../../../utils/test-utils');
22

33
describe('webpack cli', () => {
44
it('should support CommonJS file', async () => {
5-
const { exitCode, stderr, stdout } = await run(__dirname, ['-c', 'webpack.config.cjs'], false);
5+
const { exitCode, stderr, stdout } = await run(__dirname, ['-c', 'webpack.config.cjs']);
66

77
expect(exitCode).toBe(0);
88
expect(stderr).toBeFalsy();

test/build/config-lookup/dotfolder-array/dotfolder-array.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const { run } = require('../../../utils/test-utils');
55

66
describe('dotfolder array config lookup', () => {
77
it('should find a webpack array configuration in a dotfolder', async () => {
8-
const { exitCode, stderr, stdout } = await run(__dirname, [], false);
8+
const { exitCode, stderr, stdout } = await run(__dirname, []);
99

1010
expect(exitCode).toBe(0);
1111
expect(stderr).toBeFalsy();

test/build/config-lookup/dotfolder-single/dotfolder-single.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const { run } = require('../../../utils/test-utils');
77

88
describe('dotfolder single config lookup', () => {
99
it('should find a webpack configuration in a dotfolder', async () => {
10-
const { exitCode, stderr, stdout } = await run(__dirname, [], false);
10+
const { exitCode, stderr, stdout } = await run(__dirname, []);
1111

1212
expect(exitCode).toBe(0);
1313
expect(stderr).toBeFalsy();

test/build/config-lookup/relative/basic-config.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ const { run } = require('../../../utils/test-utils');
44

55
describe('relative path to config', () => {
66
it('should work', async () => {
7-
const { exitCode, stderr, stdout } = await run(__dirname, ['-c', 'webpack.config.js', '--output-path', './binary/a'], false);
7+
const { exitCode, stderr, stdout } = await run(__dirname, ['-c', 'webpack.config.js', '--output-path', './binary/a']);
88

99
expect(exitCode).toBe(0);
1010
expect(stderr).toBeFalsy();
1111
expect(stdout).toBeTruthy();
1212
});
1313

1414
it('should work #2', async () => {
15-
const { exitCode, stderr, stdout } = await run(__dirname, ['-c', './webpack.config.js', '--output-path', './binary/b'], false);
15+
const { exitCode, stderr, stdout } = await run(__dirname, ['-c', './webpack.config.js', '--output-path', './binary/b']);
1616

1717
expect(exitCode).toBe(0);
1818
expect(stderr).toBeFalsy();

test/build/config-name/config-name.test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const { run } = require('../../utils/test-utils');
44

55
describe('--config-name flag', () => {
66
it('should select only the config whose name is passed with --config-name', async () => {
7-
const { exitCode, stderr, stdout } = await run(__dirname, ['--config-name', 'first'], false);
7+
const { exitCode, stderr, stdout } = await run(__dirname, ['--config-name', 'first']);
88

99
expect(exitCode).toBe(0);
1010
expect(stderr).toBeFalsy();
@@ -14,7 +14,7 @@ describe('--config-name flag', () => {
1414
});
1515

1616
it('should work with multiple values for --config-name', async () => {
17-
const { exitCode, stderr, stdout } = await run(__dirname, ['--config-name', 'first', '--config-name', 'third'], false);
17+
const { exitCode, stderr, stdout } = await run(__dirname, ['--config-name', 'first', '--config-name', 'third']);
1818

1919
expect(exitCode).toBe(0);
2020
expect(stderr).toBeFalsy();
@@ -39,15 +39,15 @@ describe('--config-name flag', () => {
3939
});
4040

4141
it('should log error if invalid config name is provided', async () => {
42-
const { exitCode, stderr, stdout } = await run(__dirname, ['--config-name', 'test'], false);
42+
const { exitCode, stderr, stdout } = await run(__dirname, ['--config-name', 'test']);
4343

4444
expect(exitCode).toBe(2);
4545
expect(stderr).toContain('Configuration with the name "test" was not found.');
4646
expect(stdout).toBeFalsy();
4747
});
4848

4949
it('should log error if multiple configurations are not found', async () => {
50-
const { exitCode, stderr, stdout } = await run(__dirname, ['--config-name', 'test', '-c', 'single-config.js'], false);
50+
const { exitCode, stderr, stdout } = await run(__dirname, ['--config-name', 'test', '-c', 'single-config.js']);
5151

5252
expect(exitCode).toBe(2);
5353
expect(stderr).toContain('Configuration with the name "test" was not found.');
@@ -80,7 +80,7 @@ describe('--config-name flag', () => {
8080
});
8181

8282
it('should work with config as a function', async () => {
83-
const { exitCode, stderr, stdout } = await run(__dirname, ['--config', 'function-config.js', '--config-name', 'first'], false);
83+
const { exitCode, stderr, stdout } = await run(__dirname, ['--config', 'function-config.js', '--config-name', 'first']);
8484

8585
expect(exitCode).toBe(0);
8686
expect(stderr).toBeFalsy();
@@ -104,7 +104,7 @@ describe('--config-name flag', () => {
104104
});
105105

106106
it('should log error if invalid config name is provided ', async () => {
107-
const { exitCode, stderr, stdout } = await run(__dirname, ['--config', 'function-config.js', '--config-name', 'test'], false);
107+
const { exitCode, stderr, stdout } = await run(__dirname, ['--config', 'function-config.js', '--config-name', 'test']);
108108

109109
expect(exitCode).toBe(2);
110110
expect(stderr).toContain('Configuration with the name "test" was not found.');

test/build/config/absent/config-absent.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const { run } = require('../../../utils/test-utils');
55

66
describe('Config:', () => {
77
it('supplied config file is absent', async () => {
8-
const { exitCode, stderr, stdout } = await run(__dirname, ['-c', path.resolve(__dirname, 'webpack.config.js')], false);
8+
const { exitCode, stderr, stdout } = await run(__dirname, ['-c', path.resolve(__dirname, 'webpack.config.js')]);
99

1010
// should throw with correct exit code
1111
expect(exitCode).toBe(2);

test/build/config/basic/basic-config.test.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ const { run } = require('../../../utils/test-utils');
55

66
describe('basic config file', () => {
77
it('is able to understand and parse a very basic configuration file', async () => {
8-
const { exitCode, stderr, stdout } = await run(
9-
__dirname,
10-
['-c', resolve(__dirname, 'webpack.config.js'), '--output-path', './binary'],
11-
false,
12-
);
8+
const { exitCode, stderr, stdout } = await run(__dirname, [
9+
'-c',
10+
resolve(__dirname, 'webpack.config.js'),
11+
'--output-path',
12+
'./binary',
13+
]);
1314
expect(exitCode).toBe(0);
1415
expect(stderr).toBeFalsy();
1516
expect(stdout).toBeTruthy();

test/build/config/defaults/basic-config/default-js-config.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const { run, isWebpack5 } = require('../../../../utils/test-utils');
44

55
describe('Zero Config', () => {
66
it('runs when config is present but not supplied via flag', async () => {
7-
const { exitCode, stderr, stdout } = await run(__dirname, [], false);
7+
const { exitCode, stderr, stdout } = await run(__dirname, []);
88

99
expect(exitCode).toEqual(0);
1010
expect(stderr).toBeFalsy();

test/build/config/defaults/cjs-config/default-cjs-config.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const { run, isWebpack5 } = require('../../../../utils/test-utils');
44

55
describe('Default Config:', () => {
66
it('Should be able to pick cjs config by default', async () => {
7-
const { exitCode, stderr, stdout } = await run(__dirname, [], false);
7+
const { exitCode, stderr, stdout } = await run(__dirname, []);
88

99
expect(exitCode).toEqual(0);
1010
expect(stderr).toBeFalsy();

test/build/config/defaults/dot-webpack-directory-webpackfile/multiple-location-config.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const { run } = require('../../../../utils/test-utils');
55

66
describe('multiple dev config files with webpack.config.js', () => {
77
it('Uses webpack.config.development.js', async () => {
8-
const { stdout, stderr, exitCode } = await run(__dirname, [], false);
8+
const { stdout, stderr, exitCode } = await run(__dirname, []);
99
expect(exitCode).toEqual(0);
1010
expect(stderr).toBeFalsy();
1111
expect(stdout).not.toBe(undefined);

test/build/config/defaults/dot-webpack-directory/dev-none-config.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const { run } = require('../../../../utils/test-utils');
55

66
describe('multiple config files', () => {
77
it('Uses dev config when both dev and none are present', async () => {
8-
const { stdout, stderr, exitCode } = await run(__dirname, [], false);
8+
const { stdout, stderr, exitCode } = await run(__dirname, []);
99
expect(exitCode).toEqual(0);
1010
expect(stderr).toBeFalsy();
1111
expect(stdout).not.toBe(undefined);

test/build/config/defaults/with-mode/multiple-config.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const { run } = require('../../../../utils/test-utils');
55

66
describe('multiple config files', () => {
77
it('Uses dev config when development mode is supplied', async () => {
8-
const { stdout, stderr, exitCode } = await run(__dirname, ['--mode', 'development'], false);
8+
const { stdout, stderr, exitCode } = await run(__dirname, ['--mode', 'development']);
99
expect(exitCode).toEqual(0);
1010
expect(stderr).toBeFalsy();
1111
expect(stdout).not.toBe(undefined);

test/build/config/invalid-path/invalid-path.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const { run } = require('../../../utils/test-utils');
44

55
describe('basic config file', () => {
66
it('is able to understand and parse a very basic configuration file', async () => {
7-
const { exitCode, stderr, stdout } = await run(__dirname, ['-c', path.resolve(__dirname, 'invalid-webpack.config.js')], false);
7+
const { exitCode, stderr, stdout } = await run(__dirname, ['-c', path.resolve(__dirname, 'invalid-webpack.config.js')]);
88

99
expect(exitCode).toBe(2);
1010
expect(stderr).toContain(`Failed to load '${path.resolve(__dirname, 'invalid-webpack.config.js')}' config`);

test/build/config/multiple-with-one-compilation/multiple-with-one-compilation.test.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ const { run } = require('../../../utils/test-utils');
55

66
describe('basic config file', () => {
77
it('is able to understand and parse a very basic configuration file', async () => {
8-
const { exitCode, stderr, stdout } = await run(
9-
__dirname,
10-
['-c', resolve(__dirname, 'webpack.config.js'), '--output-path', './binary'],
11-
false,
12-
);
8+
const { exitCode, stderr, stdout } = await run(__dirname, [
9+
'-c',
10+
resolve(__dirname, 'webpack.config.js'),
11+
'--output-path',
12+
'./binary',
13+
]);
1314
expect(exitCode).toBe(0);
1415
expect(stderr).toBeFalsy();
1516
expect(stdout).toBeTruthy();

0 commit comments

Comments
 (0)