All files / packages/configs/src/vitest/utils nitro.ts

100% Statements 4/4
100% Branches 0/0
100% Functions 2/2
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15                    1x 2x 2x    
import { createError } from "h3";
import { vi } from "vitest";
 
/** h3's own `createError`, for a spec that hands a mocked dependency the error Nitro would throw. */
export { createError as httpError } from "h3";
 
/**
 * Stubs the Nitro auto-imports a server spec can't import: `defineEventHandler` hands back the
 * handler and `createError` is h3's own. Call it before the dynamic `import()` of the file under test.
 */
export const stubNitro = (): void => {
    vi.stubGlobal("defineEventHandler", (handler: unknown) => handler);
    vi.stubGlobal("createError", createError);
};