Files
wehub-resource-sync 70bf21e064
Deploy (to testing) and Test Playground Preview Worker / Deploy Playground Preview Worker (testing) (push) Has been skipped
Deploy Workers Shared Staging / Deploy Workers Shared Staging (push) Failing after 0s
Prerelease / build (push) Has been skipped
Handle Changesets / Handle Changesets (push) Has been cancelled
Semgrep OSS scan / semgrep-oss (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:30:11 +08:00

50 lines
1.6 KiB
TypeScript

import { writeFile } from "node:fs/promises";
import { runInTempDir, seed } from "@cloudflare/workers-utils/test-helpers";
import { describe, it } from "vitest";
import { detectFramework } from "../../../src/details/framework-detection";
import { createMockContext } from "../../helpers/mock-context";
describe("detectFramework() / basic framework detection", () => {
runInTempDir();
const context = createMockContext();
it("defaults to the static framework when no framework is detected", async ({
expect,
}) => {
await writeFile(
"package-lock.json",
JSON.stringify({ lockfileVersion: 3 })
);
const result = await detectFramework(process.cwd(), context);
expect(result.detectedFramework.framework.id).toBe("static");
});
it("detects astro when astro is in dependencies", async ({ expect }) => {
await seed({
"package.json": JSON.stringify({ dependencies: { astro: "5" } }),
"package-lock.json": JSON.stringify({ lockfileVersion: 3 }),
});
const result = await detectFramework(process.cwd(), context);
expect(result.detectedFramework?.framework.id).toBe("astro");
expect(result.detectedFramework?.framework.name).toBe("Astro");
});
it("includes buildCommand in detectedFramework when available", async ({
expect,
}) => {
await seed({
"package.json": JSON.stringify({ dependencies: { astro: "5" } }),
"package-lock.json": JSON.stringify({ lockfileVersion: 3 }),
});
const result = await detectFramework(process.cwd(), context);
expect(result.detectedFramework?.buildCommand).toBeDefined();
expect(result.detectedFramework?.buildCommand).toContain("astro build");
});
});