25 lines
856 B
TypeScript
25 lines
856 B
TypeScript
import { readFileSync } from "node:fs";
|
|
import { join } from "node:path";
|
|
import { describe, expect, test } from "vitest";
|
|
import { createDevServerConfig } from "../../vite.config";
|
|
|
|
describe("local development runtime", () => {
|
|
test("starts the Bun API server together with the Vite dev server", () => {
|
|
const packageJson = JSON.parse(
|
|
readFileSync(join(process.cwd(), "package.json"), "utf8"),
|
|
) as { scripts?: Record<string, string> };
|
|
|
|
expect(packageJson.scripts?.dev).toBe("bun src/server/dev.ts");
|
|
});
|
|
|
|
test("proxies dashboard API requests from Vite to the Bun API server", () => {
|
|
const server = createDevServerConfig({
|
|
DASHBOARD_DEV_API_TARGET: "http://127.0.0.1:5174",
|
|
});
|
|
|
|
expect(server?.proxy?.["/api"]).toMatchObject({
|
|
target: "http://127.0.0.1:5174",
|
|
changeOrigin: true,
|
|
});
|
|
});
|
|
});
|