Skip to content

Commit

Permalink
tests(config): add config-location tests (#689)
Browse files Browse the repository at this point in the history
  • Loading branch information
lakatostamas committed Nov 18, 2018
1 parent 14ec0a5 commit 7ec1855
Show file tree
Hide file tree
Showing 12 changed files with 119 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/binCases/config-location/find-recursively/index2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = "find-recursively";
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`find-recursively 1`] = `
"Child
Asset Size Chunks Chunk Names
main.js 958 bytes 0 [emitted] main
Entrypoint main = main.js
[0] /Users/tamaslakatos/playground/webpack-cli/test/binCases/config-location/find-recursively/index2.js 37 bytes {0} [built]"
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"use strict";

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

test("find-recursively", () => {
const { code, stdout, stderr } = run(__dirname, [
"--output-filename",
"[name].js",
"--output-chunk-filename",
"[id].chunk.js",
"--target",
"async-node",
"--mode",
"production"
]);
expect(code).toBe(0);
expect(stdout).toEqual(expect.anything());
expect(stdout).toContain("/index2.js");
expect(stderr).toHaveLength(0);
expect(stdout).toMatchSnapshot();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
var path = require("path");

module.exports = [
{
entry: path.resolve(__dirname, "./index2")
},
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`set-explicitly 1`] = `
" Asset Size Chunks Chunk Names
main.js 956 bytes 0 [emitted] main
Entrypoint main = main.js
[0] ./index.js 35 bytes {0} [built]"
`;
1 change: 1 addition & 0 deletions test/binCases/config-location/set-explicitly/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = "set-explicitly";
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"use strict";

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

test("set-explicitly", () => {
const { code, stdout, stderr } = run(__dirname, [
"--config",
"./webpack.dev.js",
"--config-name",
"foo",
"--output-filename",
"[name].js",
"--output-chunk-filename",
"[id].chunk.js",
"--target",
"async-node",
"--mode",
"production",
]);
expect(code).toBe(0);
expect(stdout).toEqual(expect.anything());
expect(stdout).toContain("./index.js");
expect(stderr).toHaveLength(0);
expect(stdout).toMatchSnapshot();
});
8 changes: 8 additions & 0 deletions test/binCases/config-location/set-explicitly/webpack.dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
var path = require("path");

module.exports = [
{
name: "foo",
entry: path.resolve(__dirname, "./index")
},
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`set-implicitly 1`] = `
"Child foo:
Asset Size Chunks Chunk Names
main.js 956 bytes 0 [emitted] main
Entrypoint main = main.js
[0] ./index2.js 35 bytes {0} [built]"
`;
1 change: 1 addition & 0 deletions test/binCases/config-location/set-implicitly/index2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = "set-implicitly";
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"use strict";

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

test("set-implicitly", () => {
const { code, stdout, stderr } = run(__dirname, [
"--output-filename",
"[name].js",
"--output-chunk-filename",
"[id].chunk.js",
"--target",
"async-node",
"--mode",
"production",
]);
expect(code).toBe(0);
expect(stdout).toEqual(expect.anything());
expect(stdout).toContain("./index2.js");
expect(stderr).toHaveLength(0);
expect(stdout).toMatchSnapshot();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
var path = require("path");

module.exports = [
{
name: "foo",
entry: path.resolve(__dirname, "./index2")
},
];

0 comments on commit 7ec1855

Please sign in to comment.