diff --git a/test/colors/colors.test.js b/test/colors/colors.test.js index 85815bc1d9e..7cbbee8fc1f 100644 --- a/test/colors/colors.test.js +++ b/test/colors/colors.test.js @@ -5,7 +5,7 @@ const { options: coloretteOptions } = require('colorette'); describe('colors related tests', () => { it('should output by default', () => { - const { stderr, stdout, exitCode } = run(__dirname); + const { stderr, stdout, exitCode } = run(__dirname, ['--mode', 'production']); expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; @@ -14,7 +14,7 @@ describe('colors related tests', () => { }); it('should work with the "stats" option from flags', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--stats=verbose']); + const { stderr, stdout, exitCode } = run(__dirname, ['--stats=verbose', '--mode', 'production']); expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; @@ -26,6 +26,8 @@ describe('colors related tests', () => { const { stderr, stdout, exitCode } = run(__dirname, [ '--stats=verbose', `--config=${resolve(__dirname, './no-stats.webpack.config.js')}`, + '--mode', + 'production', ]); expect(stderr).toBeFalsy(); @@ -35,7 +37,12 @@ describe('colors related tests', () => { }); it('should work with the "stats" option from flags and from configuration #2', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--stats=verbose', '--config=stats-string.webpack.config.js']); + const { stderr, stdout, exitCode } = run(__dirname, [ + '--stats=verbose', + '--config=stats-string.webpack.config.js', + '--mode', + 'production', + ]); expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; @@ -44,7 +51,7 @@ describe('colors related tests', () => { }); it('should disable colored output with --no-color', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--stats=verbose', '--no-color']); + const { stderr, stdout, exitCode } = run(__dirname, ['--stats=verbose', '--no-color', '--mode', 'production']); expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; @@ -54,7 +61,7 @@ describe('colors related tests', () => { }); it('should work with the "stats" option and --color flags', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--stats=verbose', '--color']); + const { stderr, stdout, exitCode } = run(__dirname, ['--stats=verbose', '--color', '--mode', 'production']); expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; @@ -63,7 +70,7 @@ describe('colors related tests', () => { }); it('should work with the "stats" option from the configuration', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--config=stats-string.webpack.config.js']); + const { stderr, stdout, exitCode } = run(__dirname, ['--config=stats-string.webpack.config.js', '--mode', 'production']); expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; @@ -72,7 +79,7 @@ describe('colors related tests', () => { }); it('should work with the "stats" option from the configuration #1', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--config=stats-boolean.webpack.config.js']); + const { stderr, stdout, exitCode } = run(__dirname, ['--config=stats-boolean.webpack.config.js', '--mode', 'production']); expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; @@ -81,7 +88,7 @@ describe('colors related tests', () => { }); it('should work with the "stats" option from the configuration #2', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--config=no-stats.webpack.config.js']); + const { stderr, stdout, exitCode } = run(__dirname, ['--config=no-stats.webpack.config.js', '--mode', 'production']); expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; @@ -90,7 +97,7 @@ describe('colors related tests', () => { }); it('should work with the "stats" option from the configuration #3', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--config=colors-true.webpack.config.js']); + const { stderr, stdout, exitCode } = run(__dirname, ['--config=colors-true.webpack.config.js', '--mode', 'production']); expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; @@ -99,7 +106,7 @@ describe('colors related tests', () => { }); it('should work with the "stats" option from the configuration #4', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--config=colors-false.webpack.config.js']); + const { stderr, stdout, exitCode } = run(__dirname, ['--config=colors-false.webpack.config.js', '--mode', 'production']); expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; @@ -110,7 +117,7 @@ describe('colors related tests', () => { }); it('should prioritize --color over colors in config', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--config=colors-false.webpack.config.js', '--color']); + const { stderr, stdout, exitCode } = run(__dirname, ['--config=colors-false.webpack.config.js', '--color', '--mode', 'production']); expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; @@ -120,7 +127,12 @@ describe('colors related tests', () => { }); it('should prioratize --no-color over colors in config', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--config=colors-true.webpack.config.js', '--no-color']); + const { stderr, stdout, exitCode } = run(__dirname, [ + '--config=colors-true.webpack.config.js', + '--no-color', + '--mode', + 'production', + ]); expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; @@ -131,7 +143,7 @@ describe('colors related tests', () => { }); it('should work in multicompiler mode', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--config=multiple-configs.js', '--color']); + const { stderr, stdout, exitCode } = run(__dirname, ['--config=multiple-configs.js', '--color', '--mode', 'production']); expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); diff --git a/test/watch/watch-flag.test.js b/test/watch/watch-flag.test.js index e326fed48d8..fc6d3c153a8 100644 --- a/test/watch/watch-flag.test.js +++ b/test/watch/watch-flag.test.js @@ -10,7 +10,7 @@ const wordsInStatsv5 = ['asset', 'index.js', 'compiled successfully']; describe('--watch flag', () => { it('should recompile upon file change', (done) => { - const proc = runAndGetWatchProc(__dirname, ['--watch'], false, '', true); + const proc = runAndGetWatchProc(__dirname, ['--watch', '--mode', 'production'], false, '', true); let semaphore = 0; proc.stdout.on('data', (chunk) => { const data = stripAnsi(chunk.toString()); @@ -45,7 +45,7 @@ describe('--watch flag', () => { }); it('should print compilation lifecycle', (done) => { - const proc = runAndGetWatchProc(__dirname, ['--watch'], false, '', true); + const proc = runAndGetWatchProc(__dirname, ['--watch', '--mode', 'production'], false, '', true); let semaphore = 0; proc.stdout.on('data', (chunk) => { const data = stripAnsi(chunk.toString());