chore: speed up tests (#1791)
This PR speeds up tests by handling custom created `Requests` object directly instead of binding a socket and making a real HTTP request. For most tests this is fine, and for those that aren't the existing testing methods are all preserved.
This commit is contained in:
@@ -91,6 +91,11 @@ interface StaticFile {
|
||||
etag: string;
|
||||
}
|
||||
|
||||
export type FromManifestOptions = FreshOptions & {
|
||||
skipSnapshot?: boolean;
|
||||
dev?: boolean;
|
||||
};
|
||||
|
||||
export class ServerContext {
|
||||
#dev: boolean;
|
||||
#routes: Route[];
|
||||
@@ -149,7 +154,7 @@ export class ServerContext {
|
||||
*/
|
||||
static async fromManifest(
|
||||
manifest: Manifest,
|
||||
opts: FreshOptions & { skipSnapshot?: boolean; dev?: boolean },
|
||||
opts: FromManifestOptions,
|
||||
): Promise<ServerContext> {
|
||||
const dev = Deno.env.get("__FRSH_LEGACY_DEV") === "true" ||
|
||||
Boolean(opts.dev);
|
||||
@@ -907,9 +912,8 @@ export class ServerContext {
|
||||
"%cAn error occurred during route handling or page rendering.",
|
||||
"color:red",
|
||||
);
|
||||
let codeFrame: string | undefined = undefined;
|
||||
if (this.#dev && error instanceof Error) {
|
||||
codeFrame = await getCodeFrame(error);
|
||||
const codeFrame = await getCodeFrame(error);
|
||||
|
||||
if (codeFrame) {
|
||||
console.error();
|
||||
|
||||
Reference in New Issue
Block a user