Skip to content

Commit

Permalink
tests: fix
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait committed Nov 30, 2020
1 parent b21e07a commit 232fdf9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
21 changes: 9 additions & 12 deletions test/cache/cache.test.js
Expand Up @@ -16,10 +16,9 @@ describe('cache', () => {
it('should work', () => {
let { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.config.js', '--cache-name', 'test'], false);

expect(stderr).toContain('Compilation starting...');
expect(stderr).toContain('Compilation finished');

if (isWebpack5) {
expect(stderr).toContain('Compilation starting...');
expect(stderr).toContain('Compilation finished');
expect(stderr).toContain('No pack exists at');
expect(stderr).toContain('Stored pack');
expect(stdout).toBeTruthy();
Expand All @@ -29,11 +28,10 @@ describe('cache', () => {

({ exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.config.js', '--cache-name', 'test'], false));

expect(stderr).toContain('Compilation starting...');
expect(stderr).toContain('Compilation finished');

if (isWebpack5) {
expect(exitCode).toEqual(0);
expect(stderr).toContain('Compilation starting...');
expect(stderr).toContain('Compilation finished');
expect(stderr).toContain('restore cache container');
expect(stderr).toContain('restore cache content metadata');
expect(stderr).toContain('restore cache content');
Expand All @@ -46,10 +44,10 @@ describe('cache', () => {
it('should work with autoloading configuration', () => {
let { exitCode, stderr, stdout } = run(__dirname, ['--cache-name', 'test-1'], false);

expect(stderr).toContain('Compilation starting...');
expect(stderr).toContain('Compilation finished');

if (isWebpack5) {
expect(exitCode).toEqual(0);
expect(stderr).toContain('Compilation starting...');
expect(stderr).toContain('Compilation finished');
expect(stderr).toContain('No pack exists at');
expect(stderr).toContain('Stored pack');
expect(stdout).toBeTruthy();
Expand All @@ -59,11 +57,10 @@ describe('cache', () => {

({ exitCode, stderr, stdout } = run(__dirname, ['--cache-name', 'test-1'], false));

expect(stderr).toContain('Compilation starting...');
expect(stderr).toContain('Compilation finished');

if (isWebpack5) {
expect(exitCode).toEqual(0);
expect(stderr).toContain('Compilation starting...');
expect(stderr).toContain('Compilation finished');
expect(stderr).toContain('restore cache container');
expect(stderr).toContain('restore cache content metadata');
expect(stderr).toContain('restore cache content');
Expand Down
4 changes: 2 additions & 2 deletions test/watch/watch-flag.test.js
Expand Up @@ -26,7 +26,7 @@ describe('--watch flag', () => {
proc.stdout.on('data', (chunk) => {
const data = stripAnsi(chunk.toString());

if ((semaphore === 1 || semaphore === 6) && data.includes('index.js')) {
if (((isWebpack5 && semaphore === 1) || (!isWebpack5 && semaphore === 2) || semaphore === 6) && data.includes('index.js')) {
if (isWebpack5) {
for (const word of wordsInStatsv5) {
expect(data).toContain(word);
Expand All @@ -48,7 +48,7 @@ describe('--watch flag', () => {
semaphore++;
}

if (semaphore === 2 && data.includes('Compilation finished')) {
if (((isWebpack5 && semaphore === 2) || (!isWebpack5 && semaphore === 1)) && data.includes('Compilation finished')) {
semaphore++;
}

Expand Down

0 comments on commit 232fdf9

Please sign in to comment.