|
| 1 | +const { run } = require("../../../utils/test-utils"); |
| 2 | +const { existsSync, unlinkSync } = require("fs"); |
| 3 | +const { resolve } = require("path"); |
| 4 | + |
| 5 | +// eslint-disable-next-line node/no-unpublished-require |
| 6 | +const execa = require("execa"); |
| 7 | +const { sync: spawnSync } = execa; |
| 8 | + |
| 9 | +describe("webpack cli", () => { |
| 10 | + it('should work with the "disable-interpret" option from flags', async () => { |
| 11 | + const configFileName = "webpack.config"; |
| 12 | + const configFilePath = resolve(__dirname, `${configFileName}.ts`); |
| 13 | + const buildScripts = spawnSync("yarn", ["tsc", configFilePath]); |
| 14 | + expect(buildScripts.stdout).toBeTruthy(); |
| 15 | + |
| 16 | + const { exitCode, stderr, stdout } = await run(__dirname, ["--disable-interpret"]); |
| 17 | + unlinkSync(resolve(__dirname, `${configFileName}.js`)); |
| 18 | + |
| 19 | + expect(stderr).toBeFalsy(); |
| 20 | + expect(stdout).toBeTruthy(); |
| 21 | + expect(exitCode).toBe(0); |
| 22 | + expect(existsSync(resolve(__dirname, "dist/foo.bundle.js"))).toBeTruthy(); |
| 23 | + }); |
| 24 | + |
| 25 | + it("should log error without transpilation", async () => { |
| 26 | + const { exitCode, stderr, stdout } = await run(__dirname, ["--disable-interpret"]); |
| 27 | + |
| 28 | + expect(exitCode).toBe(2); |
| 29 | + expect(stderr).toContain(`Failed to load '${resolve(__dirname, "webpack.config.ts")}' config`); |
| 30 | + expect(stdout).toBeFalsy(); |
| 31 | + }); |
| 32 | +}); |
0 commit comments