-
-
Notifications
You must be signed in to change notification settings - Fork 591
/
default-mjs-config.test.js
33 lines (29 loc) · 1.11 KB
/
default-mjs-config.test.js
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
const fs = require("fs");
const path = require("path");
const { run, isWebpack5 } = require("../../../../utils/test-utils");
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 },
});
if (/Error: Not supported/.test(stderr)) {
expect(exitCode).toEqual(2);
expect(stdout).toBeFalsy();
} else {
expect(exitCode).toEqual(0);
expect(stderr).toBeFalsy();
// default entry should be used
expect(stdout).toContain("./src/index.js");
// should pick up the output path from config
expect(stdout).toContain("test-output");
if (!isWebpack5) {
expect(stdout).toContain("Hash");
expect(stdout).toContain("Version");
expect(stdout).toContain("Built at");
expect(stdout).toContain("Time");
}
// check that the output file exists
expect(fs.existsSync(path.join(__dirname, "/dist/test-output.js"))).toBeTruthy();
}
});
});