Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: config tests #2939

Merged
merged 24 commits into from Sep 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
2ed5a3b
fix: absent config test
rishabh3112 Sep 8, 2021
a3189d3
chore: basic config description
rishabh3112 Sep 8, 2021
3c8f86d
chore: update default js config test
rishabh3112 Sep 9, 2021
17e74a9
chore: update dot webpack config test
rishabh3112 Sep 9, 2021
e7cb555
chore: update dot webpack webpackfile test
rishabh3112 Sep 13, 2021
83dc51e
chore: fix description of cjs config
rishabh3112 Sep 13, 2021
8491c7c
chore: rebase
rishabh3112 Sep 13, 2021
e9b603d
chore: update mjs config
rishabh3112 Sep 14, 2021
c1d4b2d
chore: default config with mode
rishabh3112 Sep 14, 2021
9a100e3
chore: fix empty test
rishabh3112 Sep 16, 2021
06f0cf9
chore: update empty array
rishabh3112 Sep 16, 2021
8b0d0f4
chore: update empty function descriptions
rishabh3112 Sep 16, 2021
8b94970
chore: update empty promise
rishabh3112 Sep 16, 2021
222f218
chore: update config array error
rishabh3112 Sep 16, 2021
82483ae
chore: update no config
rishabh3112 Sep 16, 2021
4396bd8
chore: update invalid path file
rishabh3112 Sep 18, 2021
ba0bc3d
chore: update config error test
rishabh3112 Sep 18, 2021
c8e63fc
chore: fix funtional config test
rishabh3112 Sep 18, 2021
e44fa0e
chore: invalid export
rishabh3112 Sep 18, 2021
135df61
chore: update multiple config test
rishabh3112 Sep 21, 2021
4fde8e5
chore: update config test
rishabh3112 Sep 21, 2021
a51361c
chore: update no code test
rishabh3112 Sep 21, 2021
21d60be
chore: update no config array test
rishabh3112 Sep 21, 2021
c3d0744
chore: update no config object test
rishabh3112 Sep 21, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions test/build/config/absent/config-absent.test.js
Expand Up @@ -3,8 +3,8 @@
const path = require("path");
const { run } = require("../../../utils/test-utils");

describe("Config:", () => {
it("supplied config file is absent", async () => {
describe("config flag with non existent file", () => {
it("should throw error with non-existent configuration file", async () => {
const { exitCode, stderr, stdout } = await run(__dirname, [
"-c",
path.resolve(__dirname, "webpack.config.js"),
Expand Down
9 changes: 0 additions & 9 deletions test/build/config/absent/webpack.config-absent.js

This file was deleted.

2 changes: 1 addition & 1 deletion test/build/config/basic/basic-config.test.js
Expand Up @@ -4,7 +4,7 @@ const { resolve } = require("path");
const { run } = require("../../../utils/test-utils");

describe("basic config file", () => {
it("is able to understand and parse a very basic configuration file", async () => {
it("should build and not throw error with a basic configuration file", async () => {
const { exitCode, stderr, stdout } = await run(__dirname, [
"-c",
resolve(__dirname, "webpack.config.js"),
Expand Down
Expand Up @@ -2,8 +2,8 @@ const fs = require("fs");
const path = require("path");
const { run, isWebpack5 } = require("../../../../utils/test-utils");

describe("Zero Config", () => {
it("runs when config is present but not supplied via flag", async () => {
describe("default config", () => {
it("should build and not throw error when config is present but not supplied via flag", async () => {
const { exitCode, stderr, stdout } = await run(__dirname, []);

expect(exitCode).toEqual(0);
Expand Down
Expand Up @@ -2,8 +2,8 @@ const fs = require("fs");
const path = require("path");
const { run, isWebpack5 } = require("../../../../utils/test-utils");

describe("Default Config:", () => {
it("Should be able to pick cjs config by default", async () => {
describe("default config with cjs extention", () => {
it("should build and not throw error with cjs config by default", async () => {
const { exitCode, stderr, stdout } = await run(__dirname, []);

expect(exitCode).toEqual(0);
Expand Down
Expand Up @@ -3,8 +3,8 @@ const { existsSync } = require("fs");
const { resolve } = require("path");
const { run } = require("../../../../utils/test-utils");

describe("multiple dev config files with webpack.config.js", () => {
it("Uses webpack.config.development.js", async () => {
describe(".webpack webpackfile", () => {
it("should build and not throw with .webpack webpackfile", async () => {
const { stdout, stderr, exitCode } = await run(__dirname, []);
expect(exitCode).toEqual(0);
expect(stderr).toBeFalsy();
Expand Down
Expand Up @@ -3,8 +3,8 @@ const { existsSync } = require("fs");
const { resolve } = require("path");
const { run } = require("../../../../utils/test-utils");

describe("multiple config files", () => {
it("Uses dev config when both dev and none are present", async () => {
describe(".webpack configuration file", () => {
it("should build and not throw error when config is present in .webpack", async () => {
const { stdout, stderr, exitCode } = await run(__dirname, []);
expect(exitCode).toEqual(0);
expect(stderr).toBeFalsy();
Expand Down
Expand Up @@ -2,8 +2,8 @@ const fs = require("fs");
const path = require("path");
const { run, isWebpack5 } = require("../../../../utils/test-utils");

describe("Default Config:", () => {
it("Should be able to pick mjs config by default", async () => {
describe("default config with mjs extention", () => {
it("should build and not throw error with mjs config by default", async () => {
const { exitCode, stderr, stdout } = await run(__dirname, [], {
env: { WEBPACK_CLI_FORCE_LOAD_ESM_CONFIG: true },
});
Expand Down
Expand Up @@ -3,8 +3,8 @@ const { existsSync } = require("fs");
const { resolve } = require("path");
const { run } = require("../../../../utils/test-utils");

describe("multiple config files", () => {
it("Uses dev config when development mode is supplied", async () => {
describe("default config with mode from cli", () => {
it("should build and not throw error with development mode supplied", async () => {
const { stdout, stderr, exitCode } = await run(__dirname, ["--mode", "development"]);
expect(exitCode).toEqual(0);
expect(stderr).toBeFalsy();
Expand Down
4 changes: 2 additions & 2 deletions test/build/config/empty-array/empty-array.test.js
Expand Up @@ -2,8 +2,8 @@
const { resolve } = require("path");
const { run } = require("../../../utils/test-utils");

describe("config flag with empty config file", () => {
it("should throw error with no configuration or index file", async () => {
describe("config flag with config file returning empty array", () => {
it("should build and not throw error with no configuration or index file", async () => {
const { exitCode, stderr, stdout } = await run(__dirname, [
"-c",
resolve(__dirname, "webpack.config.js"),
Expand Down
4 changes: 2 additions & 2 deletions test/build/config/empty-function/empty-function.test.js
Expand Up @@ -2,8 +2,8 @@
const { resolve } = require("path");
const { run } = require("../../../utils/test-utils");

describe("config flag with empty config file", () => {
it("should throw error with no configuration or index file", async () => {
describe("config file with function returning empty object", () => {
it("should build and not throw error with no configuration or index file", async () => {
const { exitCode, stderr, stdout } = await run(__dirname, [
"-c",
resolve(__dirname, "webpack.config.js"),
Expand Down
4 changes: 2 additions & 2 deletions test/build/config/empty-promise/empty-promise.test.js
Expand Up @@ -2,8 +2,8 @@
const { resolve } = require("path");
const { run } = require("../../../utils/test-utils");

describe("config flag with empty config file", () => {
it("should throw error with no configuration or index file", async () => {
describe("config file with promise resolving empty object", () => {
it("should build and not throw error with no configuration or index file", async () => {
const { exitCode, stderr, stdout } = await run(__dirname, [
"-c",
resolve(__dirname, "webpack.config.js"),
Expand Down
2 changes: 1 addition & 1 deletion test/build/config/empty/empty.test.js
Expand Up @@ -3,7 +3,7 @@ const { resolve } = require("path");
const { run } = require("../../../utils/test-utils");

describe("config flag with empty config file", () => {
it("should throw error with no configuration or index file", async () => {
it("should build and not throw error with no configuration or index file", async () => {
const { exitCode, stderr, stdout } = await run(__dirname, [
"-c",
resolve(__dirname, "webpack.config.js"),
Expand Down
2 changes: 1 addition & 1 deletion test/build/config/error-array/config-array-error.test.js
@@ -1,7 +1,7 @@
"use strict";
const { run } = require("../../../utils/test-utils");

describe("array config error", () => {
describe("config with invalid array syntax", () => {
it("should throw syntax error and exit with non-zero exit code when even 1 object has syntax error", async () => {
const { exitCode, stderr, stdout } = await run(__dirname, ["-c", "./webpack.config.js"]);
expect(exitCode).toBe(2);
Expand Down
2 changes: 1 addition & 1 deletion test/build/config/error-commonjs/config-error.test.js
Expand Up @@ -2,7 +2,7 @@
const { resolve } = require("path");
const { run } = require("../../../utils/test-utils");

describe("config error", () => {
describe("config with errors", () => {
it("should throw error with invalid configuration", async () => {
const { exitCode, stderr, stdout } = await run(__dirname, [
"-c",
Expand Down
4 changes: 2 additions & 2 deletions test/build/config/function/functional-config.test.js
Expand Up @@ -5,7 +5,7 @@ const { existsSync } = require("fs");
const { run } = require("../../../utils/test-utils");

describe("functional config", () => {
it("should work as expected in case of single config", async () => {
it("should build and not throw error with single configuration", async () => {
const { stderr, stdout, exitCode } = await run(__dirname, [
"--config",
resolve(__dirname, "single-webpack.config.js"),
Expand All @@ -17,7 +17,7 @@ describe("functional config", () => {
expect(existsSync(resolve(__dirname, "./dist/dist-single.js"))).toBeTruthy();
});

it("should work as expected in case of multiple config", async () => {
it("should build and not throw errors with multiple configurations", async () => {
const { exitCode, stderr, stdout } = await run(__dirname, [
"--config",
resolve(__dirname, "multi-webpack.config.js"),
Expand Down
4 changes: 2 additions & 2 deletions test/build/config/invalid-export/invalid-export.test.js
Expand Up @@ -2,8 +2,8 @@
const { resolve } = require("path");
const { run } = require("../../../utils/test-utils");

describe("invalid export", () => {
it("should throw error with no configuration or index file", async () => {
describe("config with invalid export", () => {
it("should throw error with configuration exporting invalid configuration", async () => {
const { exitCode, stderr, stdout } = await run(__dirname, [
"-c",
resolve(__dirname, "webpack.config.js"),
Expand Down
1 change: 0 additions & 1 deletion test/build/config/invalid-path/a.js

This file was deleted.

4 changes: 2 additions & 2 deletions test/build/config/invalid-path/invalid-path.test.js
Expand Up @@ -2,8 +2,8 @@
const path = require("path");
const { run } = require("../../../utils/test-utils");

describe("basic config file", () => {
it("is able to understand and parse a very basic configuration file", async () => {
describe("config with invalid path supplied by CLI", () => {
it("should throw error when invalid configuration path is passed to cli", async () => {
const { exitCode, stderr, stdout } = await run(__dirname, [
"-c",
path.resolve(__dirname, "invalid-webpack.config.js"),
Expand Down
9 changes: 0 additions & 9 deletions test/build/config/invalid-path/webpack.config.js

This file was deleted.

Expand Up @@ -3,8 +3,8 @@
const { resolve } = require("path");
const { run } = require("../../../utils/test-utils");

describe("basic config file", () => {
it("is able to understand and parse a very basic configuration file", async () => {
describe("config with single config in array", () => {
it("should build and not throw error with configuration file exporting single configuration in array", async () => {
const { exitCode, stderr, stdout } = await run(__dirname, [
"-c",
resolve(__dirname, "webpack.config.js"),
Expand Down
4 changes: 2 additions & 2 deletions test/build/config/multiple/multiple-config.test.js
Expand Up @@ -2,8 +2,8 @@

const { run } = require("../../../utils/test-utils");

describe("Multiple config flag: ", () => {
it("spawns multiple compilers for multiple configs", async () => {
describe("multiple configuration files", () => {
it("should not throw error and spawn compilers for each configuration file", async () => {
const { exitCode, stderr, stdout } = await run(__dirname, [
"--config",
"webpack1.config.js",
Expand Down
2 changes: 1 addition & 1 deletion test/build/config/no-code/no-code.test.js
Expand Up @@ -3,7 +3,7 @@ const { resolve } = require("path");
const { run } = require("../../../utils/test-utils");

describe("config flag with no code", () => {
it("should not throw error with no configuration or index file", async () => {
it("should build and not throw error with no configuration or index file", async () => {
const { exitCode, stderr, stdout } = await run(__dirname, [
"-c",
resolve(__dirname, "webpack.config.js"),
Expand Down
4 changes: 2 additions & 2 deletions test/build/config/no-config-array/no-config-array.test.js
Expand Up @@ -3,8 +3,8 @@
const { resolve } = require("path");
const { run } = require("../../../utils/test-utils");

describe("no configs in array", () => {
it("is able to understand and parse a very basic configuration file", async () => {
describe("config with empty array", () => {
it("should build and not throw error with empty configuration", async () => {
const { exitCode, stderr, stdout } = await run(__dirname, [
"-c",
resolve(__dirname, "webpack.config.js"),
Expand Down
Expand Up @@ -4,7 +4,7 @@ const { resolve } = require("path");
const { run } = require("../../../utils/test-utils");

describe("empty config", () => {
it("should work", async () => {
it("should build and not throw error with empty object as configuration", async () => {
const { exitCode, stderr, stdout } = await run(__dirname, [
"-c",
resolve(__dirname, "webpack.config.js"),
Expand Down