From 3c8628c7e2310853c1a7f6a0af260cd2f539ce7f Mon Sep 17 00:00:00 2001 From: Hemal Patel Date: Mon, 10 Dec 2018 00:07:43 +0530 Subject: [PATCH] tests(errors): use extractSummary --- .../clean-webpack-options.test.js | 8 +++++--- .../errors/issue-5576/issue-5576.test.js | 6 ++++-- test/binCases/errors/parse/parse.test.js | 18 ++++++++++-------- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/test/binCases/errors/clean-webpack-options/clean-webpack-options.test.js b/test/binCases/errors/clean-webpack-options/clean-webpack-options.test.js index 198276d184c..40a6b1594b4 100644 --- a/test/binCases/errors/clean-webpack-options/clean-webpack-options.test.js +++ b/test/binCases/errors/clean-webpack-options/clean-webpack-options.test.js @@ -1,19 +1,21 @@ "use strict"; -const { run } = require("../../../testUtils"); +const { run, extractSummary } = require("../../../testUtils"); test("clean-webpack-options", () => { const { code, stdout, stderr } = run(__dirname, []); + const summary = extractSummary(stdout); + expect(code).toBe(1); - expect(stdout).toHaveLength(0); + expect(summary).toHaveLength(0); expect(stderr).toContain("Invalid configuration object."); expect(stderr).toContain("configuration.context should be a string"); expect(stderr).toContain("The base directory "); expect(stderr.split("\n")).toHaveLength(4); - expect(stdout).toMatchSnapshot(); + expect(summary).toMatchSnapshot(); expect(stderr).toMatchSnapshot(); }); diff --git a/test/binCases/errors/issue-5576/issue-5576.test.js b/test/binCases/errors/issue-5576/issue-5576.test.js index cf6c32c0d76..e67c19c0f18 100644 --- a/test/binCases/errors/issue-5576/issue-5576.test.js +++ b/test/binCases/errors/issue-5576/issue-5576.test.js @@ -1,12 +1,14 @@ "use strict"; -const { run } = require("../../../testUtils"); +const { run, extractSummary } = require("../../../testUtils"); test("info-verbosity", () => { const { stderr, stdout, code } = run(__dirname, ["a", "bundle.js", "--mode", "production"]); + const summary = extractSummary(stdout); + expect(code).toBe(2); - expect(stdout).toContain("bundle.js"); + expect(summary).toContain("bundle.js"); expect(stderr).toHaveLength(0); }); diff --git a/test/binCases/errors/parse/parse.test.js b/test/binCases/errors/parse/parse.test.js index 0a50e3ff9f8..7773c66b4f1 100644 --- a/test/binCases/errors/parse/parse.test.js +++ b/test/binCases/errors/parse/parse.test.js @@ -1,18 +1,20 @@ "use strict"; -const { run } = require("../../../testUtils"); +const { run, extractSummary } = require("../../../testUtils"); test("info-verbosity", () => { const { stderr, stdout, code } = run(__dirname, []); + const summary = extractSummary(stdout); + expect(code).toBe(2); - expect(stdout).toContain("./index.js"); - expect(stdout).toContain("[built]"); - expect(stdout).toContain("[failed]"); - expect(stdout).toContain("[1 error]"); - expect(stdout).toContain("ERROR in ./index.js"); - expect(stdout).toContain("Module parse failed:"); + expect(summary).toContain("./index.js"); + expect(summary).toContain("[built]"); + expect(summary).toContain("[failed]"); + expect(summary).toContain("[1 error]"); + expect(summary).toContain("ERROR in ./index.js"); + expect(summary).toContain("Module parse failed:"); expect(stderr).toHaveLength(0); - expect(stdout).toMatchSnapshot(); + expect(summary).toMatchSnapshot(); });