diff options
author | 2023-05-11 21:32:44 -0400 | |
---|---|---|
committer | 2023-05-11 21:32:44 -0400 | |
commit | 031492b396a0b9165f32b8c97f4bd5dc4fb8f79b (patch) | |
tree | b0ee69b70ba2bae4ff20964f19a6262888d29ab1 /test/bundler/integration/react/react-client.test.ts | |
parent | 03d453054d7c26509eca22c9d3a73c08fe33f0ca (diff) | |
download | bun-031492b396a0b9165f32b8c97f4bd5dc4fb8f79b.tar.gz bun-031492b396a0b9165f32b8c97f4bd5dc4fb8f79b.tar.zst bun-031492b396a0b9165f32b8c97f4bd5dc4fb8f79b.zip |
start vue tests
Diffstat (limited to 'test/bundler/integration/react/react-client.test.ts')
-rw-r--r-- | test/bundler/integration/react/react-client.test.ts | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/test/bundler/integration/react/react-client.test.ts b/test/bundler/integration/react/react-client.test.ts new file mode 100644 index 000000000..0785b7630 --- /dev/null +++ b/test/bundler/integration/react/react-client.test.ts @@ -0,0 +1,44 @@ +import path from "path"; +import { describe, test, expect } from "bun:test"; +import { bunExe } from "harness"; + +const modes = [ + // + { label: "base" }, + { label: "minify-all", args: ["--minify"] }, + { label: "minify-syntax", args: ["--minify-syntax"] }, + { label: "minify-whitespace", args: ["--minify-whitespace"] }, + { label: "sourcemaps", args: ["--minify", "--sourcemap=external"] }, +]; +const nodeEnvs = ["development", "production"]; +const combinations = nodeEnvs.flatMap(nodeEnv => modes.map(mode => ({ options: mode, nodeEnv }))); + +describe("bundler integration, react client", () => { + for (const { + options: { label, args }, + nodeEnv, + } of combinations) { + test(label + ", NODE_ENV=" + nodeEnv, async () => { + const out = path.join(import.meta.dir, "dist/client/" + label + "-" + nodeEnv); + const x = Bun.spawnSync( + [bunExe(), "build", ...(args ?? []), "--outdir=" + out, "--splitting", path.join(import.meta.dir, "index.jsx")], + { + // cwd: import.meta.dir + "/react", + env: nodeEnv ? { NODE_ENV: nodeEnv } : undefined, + }, + ); + if (x.exitCode !== 0) { + console.error(x.stderr.toString()); + throw new Error("Failed to build"); + } + const proc = Bun.spawn(["node", path.join(import.meta.dir, "puppeteer.mjs"), out], { + cwd: path.join(import.meta.dir, "react"), + }); + await proc.exited; + expect(proc.exitCode).toBe(0); + const output = JSON.parse(await new Response(proc.stdout).text()); + expect(output.logs).toMatchSnapshot("Browser console logs"); + expect(output.domSnapshots).toMatchSnapshot("DOM Snapshots"); + }); + } +}); |