diff --git a/test/merge/config/1.js b/test/merge/config/1.js index 5051ea4b9d9..b09ad20ba61 100644 --- a/test/merge/config/1.js +++ b/test/merge/config/1.js @@ -1,6 +1,10 @@ +const WebpackCLITestPlugin = require('../../utils/webpack-cli-test-plugin'); + module.exports = { - entry: './old_entry.js', + entry: './first-entry.js', + mode: 'development', output: { - filename: 'badfile.js', + filename: 'first-output.js', }, + plugins: [new WebpackCLITestPlugin()], }; diff --git a/test/merge/config/2.js b/test/merge/config/2.js index 2c99fa4d4b7..cdf6f428467 100644 --- a/test/merge/config/2.js +++ b/test/merge/config/2.js @@ -1,6 +1,7 @@ module.exports = { - entry: './some_entry.js', + entry: './second-entry.js', + target: 'node', output: { - filename: 'merged.js', + filename: 'second-output.js', }, }; diff --git a/test/merge/config/3.js b/test/merge/config/3.js new file mode 100644 index 00000000000..eb2a7d3a6f5 --- /dev/null +++ b/test/merge/config/3.js @@ -0,0 +1,6 @@ +module.exports = { + entry: './third-entry.js', + output: { + filename: 'third-output.js', + }, +}; diff --git a/test/merge/config/first-entry.js b/test/merge/config/first-entry.js new file mode 100644 index 00000000000..e5ba023838e --- /dev/null +++ b/test/merge/config/first-entry.js @@ -0,0 +1 @@ +console.log('first'); diff --git a/test/merge/config/merge-config.test.js b/test/merge/config/merge-config.test.js index 916eb44c750..8ac300abb4c 100644 --- a/test/merge/config/merge-config.test.js +++ b/test/merge/config/merge-config.test.js @@ -8,7 +8,22 @@ describe('merge flag configuration', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - expect(stdout).toContain('option has not been set, webpack will fallback to'); + expect(stdout).toContain('WebpackCLITestPlugin'); // from 1.js + expect(stdout).toContain('second-output.js'); // from 2.js + }); + + it('merges more than two configurations together', () => { + const { exitCode, stderr, stdout } = run( + __dirname, + ['--config', './1.js', '--config', './2.js', '--config', './3.js', '--merge'], + false, + ); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain('WebpackCLITestPlugin'); // from 1.js + expect(stdout).toContain("target: 'node'"); // from 2.js + expect(stdout).toContain('third-output.js'); // from 3.js }); it('merges two configurations together with flag alias', () => { @@ -16,11 +31,12 @@ describe('merge flag configuration', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - expect(stdout).toContain('merged.js'); + expect(stdout).toContain('WebpackCLITestPlugin'); // from 1.js + expect(stdout).toContain('second-output.js'); // from 2.js }); it('fails when there are less than 2 configurations to merge', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--config', './1.js', '-m'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['--config', './1.js', '--merge'], false); expect(exitCode).toBe(2); expect(stderr).toContain('At least two configurations are required for merge.'); diff --git a/test/merge/config/second-entry.js b/test/merge/config/second-entry.js new file mode 100644 index 00000000000..e1595dffb00 --- /dev/null +++ b/test/merge/config/second-entry.js @@ -0,0 +1 @@ +console.log('second'); diff --git a/test/merge/config/some_entry.js b/test/merge/config/some_entry.js deleted file mode 100644 index ad5fca8a5fd..00000000000 --- a/test/merge/config/some_entry.js +++ /dev/null @@ -1 +0,0 @@ -console.log('yass'); diff --git a/test/merge/config/third-entry.js b/test/merge/config/third-entry.js new file mode 100644 index 00000000000..29134430a5e --- /dev/null +++ b/test/merge/config/third-entry.js @@ -0,0 +1 @@ +console.log('third');