-
-
Notifications
You must be signed in to change notification settings - Fork 670
Expand file tree
/
Copy pathdisable-interpret.test.js
More file actions
36 lines (30 loc) · 1.39 KB
/
disable-interpret.test.js
File metadata and controls
36 lines (30 loc) · 1.39 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
const { existsSync, unlinkSync } = require("node:fs");
const { resolve } = require("node:path");
const { run } = require("../../../utils/test-utils");
describe("webpack cli", () => {
it('should work with the "disable-interpret" option from flags', async () => {
const configFileName = "webpack.config";
const configFilePath = resolve(__dirname, `${configFileName}.ts`);
const { execa } = await import("execa");
const buildScripts = await execa("yarn", ["tsc", configFilePath]);
expect(buildScripts.stdout).toBeTruthy();
const { exitCode, stderr, stdout } = await run(__dirname, ["--disable-interpret"]);
unlinkSync(resolve(__dirname, `${configFileName}.js`));
expect(stderr).toBeFalsy();
expect(stdout).toBeTruthy();
expect(exitCode).toBe(0);
expect(existsSync(resolve(__dirname, "dist/foo.bundle.js"))).toBeTruthy();
});
it("should log error without transpilation", async () => {
const [major] = process.versions.node.split(".").map(Number);
const { exitCode, stderr, stdout } = await run(__dirname, ["--disable-interpret"], {
nodeOptions: [
// Disable typescript strip types for tests
...(major >= 24 ? ["--no-experimental-strip-types"] : []),
],
});
expect(exitCode).toBe(2);
expect(stderr).toContain(`Failed to load '${resolve(__dirname, "webpack.config.ts")}' config`);
expect(stdout).toBeFalsy();
});
});