Skip to content

Commit

Permalink
tests: update:
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 committed Nov 5, 2020
1 parent d64589c commit 1615bfa
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions test/colors/colors.test.js
Expand Up @@ -16,6 +16,9 @@ describe('colorts', () => {
it('should work with the "stats" option from flags', () => {
const { stderr, stdout, exitCode } = run(__dirname, ['--stats=verbose']);

//log to check in CI
console.log('colors should be enabled by default here -');
console.log(stdout);
expect(stderr).toBeFalsy();
const output = isWebpack5 ? 'successfully' : 'main.js';
expect(stdout).toContain(coloretteOptions.enabled ? `\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m` : output);
Expand Down Expand Up @@ -43,27 +46,28 @@ describe('colorts', () => {
expect(exitCode).toBe(0);
});

it('should work with the "stats" option and --color flags', () => {
const { stderr, stdout, exitCode } = run(__dirname, ['--stats=verbose']);
it('should disable colored output with --no-color', () => {
const { stderr, stdout, exitCode } = run(__dirname, ['--stats=verbose', '--no-color']);

console.log('colors should be enabled here -');
//log to check in CI
console.log('color should be disabled here -');
console.log(stdout);
expect(stderr).toBeFalsy();
const output = isWebpack5 ? 'successfully' : 'main.js';
expect(stdout).toContain(`\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m`);
expect(stdout).not.toContain(`\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m`);
expect(stdout).toContain(output);
expect(exitCode).toBe(0);
});

it('should disable colored output with --no-color', () => {
const { stderr, stdout, exitCode } = run(__dirname, ['--stats=verbose', '--no-color']);
it('should work with the "stats" option and --color flags', () => {
const { stderr, stdout, exitCode } = run(__dirname, ['--stats=verbose', '--color']);

//log to check in CI
console.log('color should be disabled here -');
console.log('colors should be enabled here -');
console.log(stdout);
expect(stderr).toBeFalsy();
const output = isWebpack5 ? 'successfully' : 'main.js';
expect(stdout).not.toContain(`\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m`);
expect(stdout).toContain(output);
expect(stdout).toContain(`\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m`);
expect(exitCode).toBe(0);
});

Expand Down Expand Up @@ -95,10 +99,9 @@ describe('colorts', () => {
});

it('should work with the "stats" option from the configuration #3', () => {
const { stderr, stdout, exitCode } = run(__dirname, ['--config=colors-true.webpack.config.js', '--color']);
const { stderr, stdout, exitCode } = run(__dirname, ['--config=colors-true.webpack.config.js']);

expect(stderr).toBeFalsy();
console.log(stdout);
const output = isWebpack5 ? 'successfully' : 'main.js';
expect(stdout).toContain(coloretteOptions.enabled ? `\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m` : output);
expect(exitCode).toBe(0);
Expand Down

0 comments on commit 1615bfa

Please sign in to comment.