Skip to content

Commit

Permalink
test: add test case for default undefined case
Browse files Browse the repository at this point in the history
  • Loading branch information
rishabh3112 committed Sep 4, 2021
1 parent 397e6e5 commit 3f25289
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/webpack-cli/lib/webpack-cli.js
Expand Up @@ -67,8 +67,8 @@ class WebpackCLI {
}

// For babel/typescript
if (result && result.default) {
result = result.default;
if (result && "default" in result) {
result = result.default || {};
}

return result || {};
Expand Down
1 change: 1 addition & 0 deletions test/build/config/undefined-default/src/index.js
@@ -0,0 +1 @@
console.log("Tom Riddle");
16 changes: 16 additions & 0 deletions test/build/config/undefined-default/undefined-default.test.js
@@ -0,0 +1,16 @@
"use strict";
const { resolve } = require("path");
const { run } = require("../../../utils/test-utils");

describe("config flag with undefined default export config file", () => {
it("should throw error with no configuration or index file", async () => {
const { exitCode, stderr, stdout } = await run(__dirname, [
"-c",
resolve(__dirname, "webpack.config.js"),
]);

expect(exitCode).toBe(0);
expect(stderr).toBeFalsy();
expect(stdout).toBeTruthy();
});
});
1 change: 1 addition & 0 deletions test/build/config/undefined-default/webpack.config.js
@@ -0,0 +1 @@
module.exports.default = undefined;

0 comments on commit 3f25289

Please sign in to comment.