Skip to content

Commit

Permalink
tests: fix
Browse files Browse the repository at this point in the history
  • Loading branch information
anshumanv committed Nov 10, 2020
1 parent a8e7232 commit 1b70fbd
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 15 deletions.
38 changes: 25 additions & 13 deletions test/colors/colors.test.js
Expand Up @@ -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';
Expand All @@ -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';
Expand All @@ -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();
Expand All @@ -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';
Expand All @@ -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';
Expand All @@ -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';
Expand All @@ -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';
Expand All @@ -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';
Expand All @@ -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';
Expand All @@ -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';
Expand All @@ -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';
Expand All @@ -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';
Expand All @@ -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';
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions test/watch/watch-flag.test.js
Expand Up @@ -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());
Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit 1b70fbd

Please sign in to comment.