-
-
Notifications
You must be signed in to change notification settings - Fork 668
Expand file tree
/
Copy pathfunctional-config.test.js
More file actions
111 lines (94 loc) · 3.97 KB
/
functional-config.test.js
File metadata and controls
111 lines (94 loc) · 3.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
"use strict";
const { existsSync } = require("node:fs");
const { resolve } = require("node:path");
const { run } = require("../../../utils/test-utils");
describe("functional config", () => {
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"),
]);
expect(exitCode).toBe(0);
expect(stderr).toBeFalsy();
expect(stdout).toContain("./src/index.js");
expect(existsSync(resolve(__dirname, "./dist/single.js"))).toBeTruthy();
});
it("should build and not throw error with async single configuration", async () => {
const { stderr, stdout, exitCode } = await run(__dirname, [
"--config",
resolve(__dirname, "async-single-webpack.config.js"),
]);
expect(exitCode).toBe(0);
expect(stderr).toBeFalsy();
expect(stdout).toContain("./src/index.js");
expect(existsSync(resolve(__dirname, "./dist/async-single.js"))).toBeTruthy();
});
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"),
]);
expect(exitCode).toBe(0);
expect(stderr).toBeFalsy();
expect(stdout).toContain("first");
expect(stdout).toContain("second");
expect(existsSync(resolve(__dirname, "./dist/multi-first.js"))).toBeTruthy();
expect(existsSync(resolve(__dirname, "./dist/multi-second.js"))).toBeTruthy();
});
it("should build and not throw errors with async multiple configurations", async () => {
const { exitCode, stderr, stdout } = await run(__dirname, [
"--config",
resolve(__dirname, "async-multi-webpack.config.js"),
]);
expect(exitCode).toBe(0);
expect(stderr).toBeFalsy();
expect(stdout).toContain("first");
expect(stdout).toContain("second");
expect(existsSync(resolve(__dirname, "./dist/multi-async-first.js"))).toBeTruthy();
expect(existsSync(resolve(__dirname, "./dist/multi-async-second.js"))).toBeTruthy();
});
it("should build and not throw errors with promise configuration", async () => {
const { exitCode, stderr, stdout } = await run(__dirname, [
"--config",
resolve(__dirname, "promise.webpack.config.js"),
]);
expect(exitCode).toBe(0);
expect(stderr).toBeFalsy();
expect(stdout).toContain("./src/index.js");
expect(existsSync(resolve(__dirname, "./dist/promise-single.js"))).toBeTruthy();
});
it("should build and not throw errors with env configuration", async () => {
const { exitCode, stderr, stdout } = await run(__dirname, [
"--config",
resolve(__dirname, "env.config.js"),
"--env=name=env",
]);
expect(exitCode).toBe(0);
expect(stderr).toBeFalsy();
expect(stdout).toContain("./src/index.js");
expect(existsSync(resolve(__dirname, "./dist/env-single.js"))).toBeTruthy();
});
it("should build and not throw errors with async env configuration", async () => {
const { exitCode, stderr, stdout } = await run(__dirname, [
"--config",
resolve(__dirname, "async-env.config.js"),
"--env=name=env",
]);
expect(exitCode).toBe(0);
expect(stderr).toBeFalsy();
expect(stdout).toContain("./src/index.js");
expect(existsSync(resolve(__dirname, "./dist/async-env-single.js"))).toBeTruthy();
});
it("should build and not throw errors with function each multiple configurations", async () => {
const { exitCode, stderr, stdout } = await run(__dirname, [
"--config",
resolve(__dirname, "function-each-multi-webpack.config.js"),
]);
expect(exitCode).toBe(0);
expect(stderr).toBeFalsy();
expect(stdout).toContain("first");
expect(stdout).toContain("second");
expect(existsSync(resolve(__dirname, "./dist/function-each-first.js"))).toBeTruthy();
expect(existsSync(resolve(__dirname, "./dist/function-each-second.js"))).toBeTruthy();
});
});