diff --git a/test/cache/cache.test.js b/test/cache/cache.test.js index 59b260096fd..7a31586a97d 100644 --- a/test/cache/cache.test.js +++ b/test/cache/cache.test.js @@ -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(); @@ -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'); @@ -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(); @@ -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'); diff --git a/test/watch/watch-flag.test.js b/test/watch/watch-flag.test.js index 5428e07bb95..b5dd8fb734f 100644 --- a/test/watch/watch-flag.test.js +++ b/test/watch/watch-flag.test.js @@ -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); @@ -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++; }