From 7f4e504ba28202d5d3d4d53a6299e45845dead7a Mon Sep 17 00:00:00 2001 From: Hemal Patel Date: Mon, 10 Dec 2018 00:32:15 +0530 Subject: [PATCH] tests(stats): use extractSummary --- .../build-delimiter/build-delimiter.test.js | 8 ++++--- .../stats/custom-preset/custom-preset.test.js | 8 ++++--- .../stats/multi-config/multi-config.test.js | 8 ++++--- .../stats/single-config/single-config.test.js | 22 ++++++++++--------- 4 files changed, 27 insertions(+), 19 deletions(-) diff --git a/test/binCases/stats/build-delimiter/build-delimiter.test.js b/test/binCases/stats/build-delimiter/build-delimiter.test.js index e1a69bc00e5..1873bb7c566 100644 --- a/test/binCases/stats/build-delimiter/build-delimiter.test.js +++ b/test/binCases/stats/build-delimiter/build-delimiter.test.js @@ -1,6 +1,6 @@ "use strict"; -const { run } = require("../../../testUtils"); +const { run, extractSummary } = require("../../../testUtils"); test("build-delimiter", () => { const { code, stdout, stderr } = run(__dirname, [ @@ -12,8 +12,10 @@ test("build-delimiter", () => { "success" ]); + const summary = extractSummary(stdout); + expect(code).toBe(0); - expect(stdout).toContain("success"); + expect(summary).toContain("success"); expect(stderr).toHaveLength(0); - expect(stdout).toMatchSnapshot(); + expect(summary).toMatchSnapshot(); }); diff --git a/test/binCases/stats/custom-preset/custom-preset.test.js b/test/binCases/stats/custom-preset/custom-preset.test.js index f53391ae1ae..cc94ff02711 100644 --- a/test/binCases/stats/custom-preset/custom-preset.test.js +++ b/test/binCases/stats/custom-preset/custom-preset.test.js @@ -1,6 +1,6 @@ "use strict"; -const { run } = require("../../../testUtils"); +const { run, extractSummary } = require("../../../testUtils"); test("custom-preset", () => { const { code, stdout, stderr } = run(__dirname, [ @@ -15,8 +15,10 @@ test("custom-preset", () => { "--display" ]); + const summary = extractSummary(stdout); + expect(stderr).toHaveLength(0); expect(code).toBe(0); - expect(stdout).toHaveLength(0); - expect(stdout).toMatchSnapshot(); + expect(summary).toHaveLength(0); + expect(summary).toMatchSnapshot(); }); diff --git a/test/binCases/stats/multi-config/multi-config.test.js b/test/binCases/stats/multi-config/multi-config.test.js index d8a0c64130b..ee51af439d7 100644 --- a/test/binCases/stats/multi-config/multi-config.test.js +++ b/test/binCases/stats/multi-config/multi-config.test.js @@ -1,12 +1,14 @@ "use strict"; -const { run } = require("../../../testUtils"); +const { run, extractSummary } = require("../../../testUtils"); test("multi-config", () => { const { code, stdout, stderr } = run(__dirname); + const summary = extractSummary(stdout); + expect(code).toBe(0); - expect(stdout).toEqual(expect.anything()); + expect(summary).toEqual(expect.anything()); expect(stderr).toHaveLength(0); - expect(stdout).toMatchSnapshot(); + expect(summary).toMatchSnapshot(); }); diff --git a/test/binCases/stats/single-config/single-config.test.js b/test/binCases/stats/single-config/single-config.test.js index 1185dce7fb1..55f64196796 100644 --- a/test/binCases/stats/single-config/single-config.test.js +++ b/test/binCases/stats/single-config/single-config.test.js @@ -1,23 +1,25 @@ "use strict"; -jest.setTimeout(10E6); +jest.setTimeout(10e6); /* eslint-disable node/no-unsupported-features */ /* eslint-disable node/no-unsupported-features/es-syntax */ -const { run } = require("../../../testUtils"); +const { run, extractSummary } = require("../../../testUtils"); -test("single-config", async(done) => { +test("single-config", async done => { const { code, stdout, stderr } = await run(__dirname); + const summary = extractSummary(stdout); + expect(code).toBe(0); - expect(stdout).toContain(""); - expect(stdout).toContain("main.js"); - expect(stdout).toContain("chunk"); - expect(stdout).not.toContain("./index.js"); - expect(stdout).not.toContain("[built]"); - expect(stdout).toContain("1 module"); + expect(summary).toContain(""); + expect(summary).toContain("main.js"); + expect(summary).toContain("chunk"); + expect(summary).not.toContain("./index.js"); + expect(summary).not.toContain("[built]"); + expect(summary).toContain("1 module"); expect(stderr).toHaveLength(0); - expect(stdout).toMatchSnapshot(); + expect(summary).toMatchSnapshot(); done(); });