aboutsummaryrefslogtreecommitdiff
path: root/test/js/third_party/webpack/webpack.test.ts
blob: ffc8195c674e75009f6b6c20735df58e3b46a302 (plain) (blame)
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
import { bunExe, bunEnv } from "harness";
import { existsSync, rmdirSync } from "fs";
import { join } from "path";

afterEach(() => {
  rmdirSync(join(import.meta.dir, "dist"), { recursive: true });
});

test("webpack works", () => {
  Bun.spawnSync({
    cmd: [bunExe(), "-b", "webpack", "--entry", "./test.js", "-o", "./dist/test1/main.js"],
    cwd: import.meta.dir,
    env: bunEnv,
  });

  expect(existsSync(join(import.meta.dir, "dist", "test1/main.js"))).toBe(true);
});

test("webpack --watch works", async () => {
  Bun.spawnSync({
    cmd: ["timeout", "3", bunExe(), "-b", "webpack", "--entry", "./test.js", "-o", "./dist/test2/main.js", "--watch"],
    cwd: import.meta.dir,
    env: bunEnv,
  });

  expect(existsSync(join(import.meta.dir, "dist", "test2/main.js"))).toBe(true);
});