Skip to content

Commit 232fdf9

Browse files
tests: fix
1 parent b21e07a commit 232fdf9

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

test/cache/cache.test.js

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@ describe('cache', () => {
1616
it('should work', () => {
1717
let { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.config.js', '--cache-name', 'test'], false);
1818

19-
expect(stderr).toContain('Compilation starting...');
20-
expect(stderr).toContain('Compilation finished');
21-
2219
if (isWebpack5) {
20+
expect(stderr).toContain('Compilation starting...');
21+
expect(stderr).toContain('Compilation finished');
2322
expect(stderr).toContain('No pack exists at');
2423
expect(stderr).toContain('Stored pack');
2524
expect(stdout).toBeTruthy();
@@ -29,11 +28,10 @@ describe('cache', () => {
2928

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

32-
expect(stderr).toContain('Compilation starting...');
33-
expect(stderr).toContain('Compilation finished');
34-
3531
if (isWebpack5) {
3632
expect(exitCode).toEqual(0);
33+
expect(stderr).toContain('Compilation starting...');
34+
expect(stderr).toContain('Compilation finished');
3735
expect(stderr).toContain('restore cache container');
3836
expect(stderr).toContain('restore cache content metadata');
3937
expect(stderr).toContain('restore cache content');
@@ -46,10 +44,10 @@ describe('cache', () => {
4644
it('should work with autoloading configuration', () => {
4745
let { exitCode, stderr, stdout } = run(__dirname, ['--cache-name', 'test-1'], false);
4846

49-
expect(stderr).toContain('Compilation starting...');
50-
expect(stderr).toContain('Compilation finished');
51-
5247
if (isWebpack5) {
48+
expect(exitCode).toEqual(0);
49+
expect(stderr).toContain('Compilation starting...');
50+
expect(stderr).toContain('Compilation finished');
5351
expect(stderr).toContain('No pack exists at');
5452
expect(stderr).toContain('Stored pack');
5553
expect(stdout).toBeTruthy();
@@ -59,11 +57,10 @@ describe('cache', () => {
5957

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

62-
expect(stderr).toContain('Compilation starting...');
63-
expect(stderr).toContain('Compilation finished');
64-
6560
if (isWebpack5) {
6661
expect(exitCode).toEqual(0);
62+
expect(stderr).toContain('Compilation starting...');
63+
expect(stderr).toContain('Compilation finished');
6764
expect(stderr).toContain('restore cache container');
6865
expect(stderr).toContain('restore cache content metadata');
6966
expect(stderr).toContain('restore cache content');

test/watch/watch-flag.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe('--watch flag', () => {
2626
proc.stdout.on('data', (chunk) => {
2727
const data = stripAnsi(chunk.toString());
2828

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

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

0 commit comments

Comments
 (0)