|
| 1 | +/* eslint-disable jest/no-standalone-expect */ |
| 2 | +/* eslint-disable jest/expect-expect */ |
| 3 | +import childProcess from "child_process"; |
| 4 | +import path from "path"; |
| 5 | +import { testIfNodeMajorVersionIsLessThan18 } from "../../utils/testIf"; |
| 6 | + |
| 7 | +function checkBundle(bundlePath1: string, bundlePath2: string) { |
| 8 | + const process1Output = childProcess.execSync(`node ${bundlePath1}`, { encoding: "utf-8" }); |
| 9 | + expect(process1Output).toBe("undefined\n"); |
| 10 | + |
| 11 | + const process2Output = childProcess.execSync(`node ${bundlePath2}`, { encoding: "utf-8" }); |
| 12 | + expect(process2Output).toBe("undefined\n"); |
| 13 | +} |
| 14 | + |
| 15 | +describe("should not inject debug IDs when `sourcemaps.disable` is `true`", () => { |
| 16 | + test("esbuild bundle", () => { |
| 17 | + checkBundle( |
| 18 | + path.join(__dirname, "out", "esbuild", "bundle1.js"), |
| 19 | + path.join(__dirname, "out", "esbuild", "bundle2.js") |
| 20 | + ); |
| 21 | + }); |
| 22 | + |
| 23 | + test("rollup bundle", () => { |
| 24 | + checkBundle( |
| 25 | + path.join(__dirname, "out", "rollup", "bundle1.js"), |
| 26 | + path.join(__dirname, "out", "rollup", "bundle2.js") |
| 27 | + ); |
| 28 | + }); |
| 29 | + |
| 30 | + test("vite bundle", () => { |
| 31 | + checkBundle( |
| 32 | + path.join(__dirname, "out", "vite", "bundle1.js"), |
| 33 | + path.join(__dirname, "out", "vite", "bundle2.js") |
| 34 | + ); |
| 35 | + }); |
| 36 | + |
| 37 | + testIfNodeMajorVersionIsLessThan18("webpack 4 bundle", () => { |
| 38 | + checkBundle( |
| 39 | + path.join(__dirname, "out", "webpack4", "bundle1.js"), |
| 40 | + path.join(__dirname, "out", "webpack4", "bundle2.js") |
| 41 | + ); |
| 42 | + }); |
| 43 | + |
| 44 | + test("webpack 5 bundle", () => { |
| 45 | + checkBundle( |
| 46 | + path.join(__dirname, "out", "webpack5", "bundle1.js"), |
| 47 | + path.join(__dirname, "out", "webpack5", "bundle2.js") |
| 48 | + ); |
| 49 | + }); |
| 50 | +}); |
0 commit comments