Skip to content

Commit

Permalink
tests(output): use extractSummary
Browse files Browse the repository at this point in the history
  • Loading branch information
hemal7735 committed Jan 21, 2019
1 parent e7fec80 commit 8762685
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
13 changes: 8 additions & 5 deletions test/binCases/output/output-argument/output-argument.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";

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

test("output-argument", () => {
const { code, stdout } = run(__dirname, [
Expand All @@ -10,9 +10,12 @@ test("output-argument", () => {
"--target",
"async-node"
]);

const summary = extractSummary(stdout);

expect(code).toBe(0);
expect(stdout).toEqual(expect.anything());
expect(stdout).toContain("bundle.js");
expect(stdout).toMatch(/index\.js.*\{0\}/);
expect(stdout).toMatchSnapshot();
expect(summary).toEqual(expect.anything());
expect(summary).toContain("bundle.js");
expect(summary).toMatch(/index\.js.*\{0\}/);
expect(summary).toMatchSnapshot();
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";

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

const { readFileSync } = require("fs");
const { resolve } = require("path");
Expand All @@ -18,12 +18,14 @@ test("output-library-many", () => {
"key2"
]);

const summary = extractSummary(stdout);

expect(code).toBe(0);
expect(stdout).toEqual(expect.anything());
expect(stdout).toMatch(/index\.js.*\{0\}/);
expect(summary).toEqual(expect.anything());
expect(summary).toMatch(/index\.js.*\{0\}/);
expect(stderr).toHaveLength(0);
const outputPath = resolve(__dirname, "bin/main.js");
const output = readFileSync(outputPath, "utf-8");
expect(output).toContain("window.key1=window.key1||{},window.key1.key2=function");
expect(stdout).toMatchSnapshot();
expect(summary).toMatchSnapshot();
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";

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

const { readFileSync } = require("fs");
const { resolve } = require("path");
Expand All @@ -16,12 +16,14 @@ test("output-library-single", () => {
"key1"
]);

const summary = extractSummary(stdout);

expect(code).toBe(0);
expect(stdout).toEqual(expect.anything());
expect(stdout).toMatch(/index\.js.*\{0\}/);
expect(summary).toEqual(expect.anything());
expect(summary).toMatch(/index\.js.*\{0\}/);
expect(stderr).toHaveLength(0);
const outputPath = resolve(__dirname, "bin", "main.js");
const output = readFileSync(outputPath, "utf-8");
expect(output).toContain("window.key1=function");
expect(stdout).toMatchSnapshot();
expect(summary).toMatchSnapshot();
});

0 comments on commit 8762685

Please sign in to comment.