mirror of
https://github.com/gethomepage/homepage.git
synced 2026-10-11 22:39:57 +00:00
Fix api page tests creating routes
This commit is contained in:
@@ -34,7 +34,7 @@ function mockResponse() {
|
||||
|
||||
async function loadHandler() {
|
||||
vi.resetModules();
|
||||
return (await import("./index")).default;
|
||||
return (await import("pages/api/mcp/index")).default;
|
||||
}
|
||||
|
||||
describe("pages/api/mcp", () => {
|
||||
+1
-1
@@ -57,7 +57,7 @@ vi.mock("widgets/widgets", () => ({
|
||||
},
|
||||
}));
|
||||
|
||||
import handler from "./proxy";
|
||||
import handler from "pages/api/services/proxy";
|
||||
|
||||
function createReq({ method = "GET", body, query = {} } = {}) {
|
||||
return { method, body, query };
|
||||
@@ -0,0 +1,19 @@
|
||||
import { readdirSync } from "fs";
|
||||
|
||||
import { expect, it } from "vitest";
|
||||
|
||||
// Next compiles everything under src/pages into routes, so a colocated test ships
|
||||
// to users and drags its dev dependencies into the runtime image.
|
||||
function filesIn(dir, found = []) {
|
||||
readdirSync(dir, { withFileTypes: true }).forEach((entry) => {
|
||||
const path = `${dir}/${entry.name}`;
|
||||
if (entry.isDirectory()) filesIn(path, found);
|
||||
else found.push(path);
|
||||
});
|
||||
return found;
|
||||
}
|
||||
|
||||
it("keeps test files out of src/pages", () => {
|
||||
const tests = filesIn("src/pages").filter((path) => /\.(test|spec)\.[jt]sx?$/.test(path));
|
||||
expect(tests).toEqual([]);
|
||||
});
|
||||
Reference in New Issue
Block a user