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
50 lines
1.4 KiB
TypeScript
50 lines
1.4 KiB
TypeScript
import {
|
|
mockConsoleMethods,
|
|
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";
|
|
const noLockFileWarning =
|
|
"No lock file has been detected in the current working directory. This might indicate that the project is part of a workspace.";
|
|
|
|
describe("detectFramework() / lock file warning", () => {
|
|
runInTempDir();
|
|
const std = mockConsoleMethods();
|
|
const context = createMockContext();
|
|
|
|
it("warns when no lock file is detected", async ({ expect }) => {
|
|
await seed({
|
|
"package.json": JSON.stringify({ dependencies: { astro: "5" } }),
|
|
});
|
|
|
|
await detectFramework(process.cwd(), context);
|
|
|
|
expect(std.warn).toContain(noLockFileWarning);
|
|
});
|
|
|
|
it("does not warn for static projects without a lock file", async ({
|
|
expect,
|
|
}) => {
|
|
await seed({
|
|
"package.json": JSON.stringify({}),
|
|
});
|
|
|
|
await detectFramework(process.cwd(), context);
|
|
|
|
expect(std.warn).not.toContain(noLockFileWarning);
|
|
});
|
|
|
|
it("does not warn when a lock file exists", async ({ expect }) => {
|
|
await seed({
|
|
"package.json": JSON.stringify({ dependencies: { astro: "5" } }),
|
|
"package-lock.json": JSON.stringify({ lockfileVersion: 3 }),
|
|
});
|
|
|
|
await detectFramework(process.cwd(), context);
|
|
|
|
expect(std.warn).not.toContain(noLockFileWarning);
|
|
});
|
|
});
|