Skip to content

Commit 8357dbc

Browse files
hemal7735evenstensberg
authored andcommitted
tests(watch): use extractSummary
1 parent 7f4e504 commit 8357dbc

File tree

6 files changed

+57
-39
lines changed

6 files changed

+57
-39
lines changed

test/binCases/watch/info-verbosity-off/info-verbosity-off.test.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
"use strict";
22

3-
jest.setTimeout(10E6);
3+
jest.setTimeout(10e6);
44
/* eslint-disable node/no-unsupported-features */
55
/* eslint-disable node/no-unsupported-features/es-syntax */
66

7-
const { runWatch } = require("../../../testUtils");
7+
const { runWatch, extractSummary } = require("../../../testUtils");
88

9-
test("info-verbosity-off", async(done) => {
9+
test("info-verbosity-off", async done => {
1010
const result = await runWatch(__dirname, [
1111
"--entry ",
1212
"./index.js",
@@ -23,11 +23,14 @@ test("info-verbosity-off", async(done) => {
2323
"none"
2424
]);
2525
const { stdout, stderr } = result;
26-
expect(stdout).toEqual(expect.anything());
27-
expect(stdout).toContain("");
28-
expect(stdout).not.toContain("webpack is watching the files…");
26+
27+
const summary = extractSummary(stdout);
28+
29+
expect(summary).toEqual(expect.anything());
30+
expect(summary).toContain("");
31+
expect(summary).not.toContain("webpack is watching the files…");
2932

3033
expect(stderr).toHaveLength(0);
31-
expect(stdout).toMatchSnapshot();
34+
expect(summary).toMatchSnapshot();
3235
done();
3336
});

test/binCases/watch/info-verbosity-verbose/info-verbosity-verbose.test.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
"use strict";
22

3-
jest.setTimeout(10E6);
3+
jest.setTimeout(10e6);
44
/* eslint-disable node/no-unsupported-features */
55
/* eslint-disable node/no-unsupported-features/es-syntax */
66

7-
const { runWatch } = require("../../../testUtils");
7+
const { runWatch, extractSummary } = require("../../../testUtils");
88

9-
test("info-verbosity-verbose", async(done) => {
9+
test("info-verbosity-verbose", async done => {
1010
const result = await runWatch(__dirname, [
1111
"--entry ",
1212
"./index.js",
@@ -23,11 +23,14 @@ test("info-verbosity-verbose", async(done) => {
2323
"verbose"
2424
]);
2525
const { stdout, stderr } = result;
26-
expect(stdout).toEqual(expect.anything());
27-
expect(stdout).toContain("Compilation");
28-
expect(stdout).toContain("webpack is watching the files…");
26+
27+
const summary = extractSummary(stdout);
28+
29+
expect(summary).toEqual(expect.anything());
30+
expect(summary).toContain("Compilation");
31+
expect(summary).toContain("webpack is watching the files…");
2932

3033
expect(stderr).toHaveLength(0);
31-
expect(stdout).toMatchSnapshot();
34+
expect(summary).toMatchSnapshot();
3235
done();
3336
});

test/binCases/watch/multi-config-watch-opt/multi-config-watch-opt.test.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
/* eslint-disable node/no-unsupported-features */
44
/* eslint-disable node/no-unsupported-features/es-syntax */
55

6-
jest.setTimeout(10E6);
6+
jest.setTimeout(10e6);
77

8-
const { runWatch } = require("../../../testUtils");
8+
const { runWatch, extractSummary } = require("../../../testUtils");
99

10-
test("multi-config-watch-opt", async(done) => {
10+
test("multi-config-watch-opt", async done => {
1111
const result = await runWatch(__dirname, [
1212
"--entry",
1313
"./index.js",
@@ -23,12 +23,15 @@ test("multi-config-watch-opt", async(done) => {
2323
]);
2424

2525
const { stdout, stderr } = result;
26-
expect(stdout).toContain("");
27-
expect(stdout).toEqual(expect.anything());
28-
expect(stdout).toContain("");
29-
expect(stdout).toContain("webpack is watching the files…");
26+
27+
const summary = extractSummary(stdout);
28+
29+
expect(summary).toContain("");
30+
expect(summary).toEqual(expect.anything());
31+
expect(summary).toContain("");
32+
expect(summary).toContain("webpack is watching the files…");
3033

3134
expect(stderr).toHaveLength(0);
32-
expect(stdout).toMatchSnapshot();
35+
expect(summary).toMatchSnapshot();
3336
done();
3437
});
Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
"use strict";
22

3-
jest.setTimeout(10E6);
3+
jest.setTimeout(10e6);
44
/* eslint-disable node/no-unsupported-features */
55
/* eslint-disable node/no-unsupported-features/es-syntax */
66

7-
const { runWatch } = require("../../../testUtils");
7+
const { runWatch, extractSummary } = require("../../../testUtils");
88

9-
test("multi-config", async(done) => {
9+
test("multi-config", async done => {
1010
const result = await runWatch(__dirname);
1111
const { stdout, stderr } = result;
12-
expect(stdout).toContain("");
13-
expect(stdout).toContain("webpack is watching the files…");
12+
13+
const summary = extractSummary(stdout);
14+
15+
expect(summary).toContain("");
16+
expect(summary).toContain("webpack is watching the files…");
1417

1518
expect(stderr).toHaveLength(0);
16-
expect(stdout).toMatchSnapshot();
19+
expect(summary).toMatchSnapshot();
1720
done();
1821
});

test/binCases/watch/single-config-watch-opt/single-config-watch-opt.test.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
22

3-
const { runWatch } = require("../../../testUtils");
3+
const { runWatch, extractSummary } = require("../../../testUtils");
44
test("single-config-watch-opt", () => {
55
runWatch(__dirname, [
66
"--entry",
@@ -16,13 +16,16 @@ test("single-config-watch-opt", () => {
1616
"--watch"
1717
]).then(result => {
1818
const { stdout, stderr } = result;
19-
expect(stdout).toEqual(expect.anything());
20-
expect(stdout).toContain("");
21-
expect(stdout).toContain("webpack is watching the files…");
19+
20+
const summary = extractSummary(stdout);
21+
22+
expect(summary).toEqual(expect.anything());
23+
expect(summary).toContain("");
24+
expect(summary).toContain("webpack is watching the files…");
2225

2326
expect(stderr).toHaveLength(0);
2427

25-
expect(stdout).toMatchSnapshot();
28+
expect(summary).toMatchSnapshot();
2629
return;
2730
});
2831
});

test/binCases/watch/single-config/single-config.test.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
jest.setTimeout(10E6);
77

8-
const { runWatch } = require("../../../testUtils");
8+
const { runWatch, extractSummary } = require("../../../testUtils");
99

1010
test("single-config", async(done) => {
1111
const result = await runWatch(__dirname, [
@@ -23,13 +23,16 @@ test("single-config", async(done) => {
2323
]);
2424

2525
const { stdout, stderr } = result;
26-
expect(stdout).toContain("");
27-
expect(stdout).toEqual(expect.anything());
28-
expect(stdout).toContain("");
29-
expect(stdout).toContain("webpack is watching the files…");
26+
27+
const summary = extractSummary(stdout);
28+
29+
expect(summary).toContain("");
30+
expect(summary).toEqual(expect.anything());
31+
expect(summary).toContain("");
32+
expect(summary).toContain("webpack is watching the files…");
3033

3134
expect(stderr).toHaveLength(0);
32-
expect(stdout).toMatchSnapshot();
35+
expect(summary).toMatchSnapshot();
3336
done();
3437

3538
});

0 commit comments

Comments
 (0)