-
-
Notifications
You must be signed in to change notification settings - Fork 591
/
default-mjs-config.test.js
26 lines (24 loc) · 1.03 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
const fs = require("fs");
const path = require("path");
const { run } = 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");
expect(stdout).toContain("compiled successfully");
// check that the output file exists
expect(fs.existsSync(path.join(__dirname, "/dist/test-output.js"))).toBeTruthy();
}
});
});