CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/next/lib/api/test-framework.ts
Views: 687
1
// This is for unit testing.
2
3
import { createRequest, createResponse } from "node-mocks-http";
4
import type { NextApiRequest, NextApiResponse } from "next";
5
6
export function createMocks(x, y?) {
7
const req = createRequest<NextApiRequest>({
8
headers: { "content-type": "application/json" },
9
...x,
10
});
11
const res = createResponse<NextApiResponse>(y);
12
return { req, res };
13
}
14
15