chore: import upstream snapshot with attribution
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
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
This commit is contained in:
+49
@@ -0,0 +1,49 @@
|
||||
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");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user