Skip to content

Commit

Permalink
tests(errors): 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 aa0cf25 commit 3c8628c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -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();
});
6 changes: 4 additions & 2 deletions test/binCases/errors/issue-5576/issue-5576.test.js
Original file line number Diff line number Diff line change
@@ -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);
});
18 changes: 10 additions & 8 deletions test/binCases/errors/parse/parse.test.js
Original file line number Diff line number Diff line change
@@ -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();
});

0 comments on commit 3c8628c

Please sign in to comment.