Skip to content

Commit

Permalink
tests(watch): use extractSummary
Browse files Browse the repository at this point in the history
  • Loading branch information
hemal7735 authored and evenstensberg committed Feb 5, 2019
1 parent 7f4e504 commit 8357dbc
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 39 deletions.
17 changes: 10 additions & 7 deletions test/binCases/watch/info-verbosity-off/info-verbosity-off.test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"use strict";

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

const { runWatch } = require("../../../testUtils");
const { runWatch, extractSummary } = require("../../../testUtils");

test("info-verbosity-off", async(done) => {
test("info-verbosity-off", async done => {
const result = await runWatch(__dirname, [
"--entry ",
"./index.js",
Expand All @@ -23,11 +23,14 @@ test("info-verbosity-off", async(done) => {
"none"
]);
const { stdout, stderr } = result;
expect(stdout).toEqual(expect.anything());
expect(stdout).toContain("");
expect(stdout).not.toContain("webpack is watching the files…");

const summary = extractSummary(stdout);

expect(summary).toEqual(expect.anything());
expect(summary).toContain("");
expect(summary).not.toContain("webpack is watching the files…");

expect(stderr).toHaveLength(0);
expect(stdout).toMatchSnapshot();
expect(summary).toMatchSnapshot();
done();
});
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"use strict";

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

const { runWatch } = require("../../../testUtils");
const { runWatch, extractSummary } = require("../../../testUtils");

test("info-verbosity-verbose", async(done) => {
test("info-verbosity-verbose", async done => {
const result = await runWatch(__dirname, [
"--entry ",
"./index.js",
Expand All @@ -23,11 +23,14 @@ test("info-verbosity-verbose", async(done) => {
"verbose"
]);
const { stdout, stderr } = result;
expect(stdout).toEqual(expect.anything());
expect(stdout).toContain("Compilation");
expect(stdout).toContain("webpack is watching the files…");

const summary = extractSummary(stdout);

expect(summary).toEqual(expect.anything());
expect(summary).toContain("Compilation");
expect(summary).toContain("webpack is watching the files…");

expect(stderr).toHaveLength(0);
expect(stdout).toMatchSnapshot();
expect(summary).toMatchSnapshot();
done();
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
/* eslint-disable node/no-unsupported-features */
/* eslint-disable node/no-unsupported-features/es-syntax */

jest.setTimeout(10E6);
jest.setTimeout(10e6);

const { runWatch } = require("../../../testUtils");
const { runWatch, extractSummary } = require("../../../testUtils");

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

const { stdout, stderr } = result;
expect(stdout).toContain("");
expect(stdout).toEqual(expect.anything());
expect(stdout).toContain("");
expect(stdout).toContain("webpack is watching the files…");

const summary = extractSummary(stdout);

expect(summary).toContain("");
expect(summary).toEqual(expect.anything());
expect(summary).toContain("");
expect(summary).toContain("webpack is watching the files…");

expect(stderr).toHaveLength(0);
expect(stdout).toMatchSnapshot();
expect(summary).toMatchSnapshot();
done();
});
15 changes: 9 additions & 6 deletions test/binCases/watch/multi-config/multi-config.test.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
"use strict";

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

const { runWatch } = require("../../../testUtils");
const { runWatch, extractSummary } = require("../../../testUtils");

test("multi-config", async(done) => {
test("multi-config", async done => {
const result = await runWatch(__dirname);
const { stdout, stderr } = result;
expect(stdout).toContain("");
expect(stdout).toContain("webpack is watching the files…");

const summary = extractSummary(stdout);

expect(summary).toContain("");
expect(summary).toContain("webpack is watching the files…");

expect(stderr).toHaveLength(0);
expect(stdout).toMatchSnapshot();
expect(summary).toMatchSnapshot();
done();
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";

const { runWatch } = require("../../../testUtils");
const { runWatch, extractSummary } = require("../../../testUtils");
test("single-config-watch-opt", () => {
runWatch(__dirname, [
"--entry",
Expand All @@ -16,13 +16,16 @@ test("single-config-watch-opt", () => {
"--watch"
]).then(result => {
const { stdout, stderr } = result;
expect(stdout).toEqual(expect.anything());
expect(stdout).toContain("");
expect(stdout).toContain("webpack is watching the files…");

const summary = extractSummary(stdout);

expect(summary).toEqual(expect.anything());
expect(summary).toContain("");
expect(summary).toContain("webpack is watching the files…");

expect(stderr).toHaveLength(0);

expect(stdout).toMatchSnapshot();
expect(summary).toMatchSnapshot();
return;
});
});
15 changes: 9 additions & 6 deletions test/binCases/watch/single-config/single-config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

jest.setTimeout(10E6);

const { runWatch } = require("../../../testUtils");
const { runWatch, extractSummary } = require("../../../testUtils");

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

const { stdout, stderr } = result;
expect(stdout).toContain("");
expect(stdout).toEqual(expect.anything());
expect(stdout).toContain("");
expect(stdout).toContain("webpack is watching the files…");

const summary = extractSummary(stdout);

expect(summary).toContain("");
expect(summary).toEqual(expect.anything());
expect(summary).toContain("");
expect(summary).toContain("webpack is watching the files…");

expect(stderr).toHaveLength(0);
expect(stdout).toMatchSnapshot();
expect(summary).toMatchSnapshot();
done();

});

0 comments on commit 8357dbc

Please sign in to comment.