Skip to content

Latest commit

 

History

History
67 lines (39 loc) · 1.85 KB

File metadata and controls

67 lines (39 loc) · 1.85 KB

next-test-api-route-handler


next-test-api-route-handler / src / NtarhInit

Interface: NtarhInit<NextResponseJsonType>

Defined in: src/index.ts:132

Extended by

Type Parameters

NextResponseJsonType

NextResponseJsonType = unknown

Properties

rejectOnHandlerError?

optional rejectOnHandlerError: boolean

Defined in: src/index.ts:145

If false, errors thrown from within a handler are kicked up to Next.js's resolver to deal with, which is what would happen in production. If true, the testApiHandler function will reject immediately instead.

You should use rejectOnHandlerError whenever you want to manually handle an error that bubbles up from your handler (which is especially true if you're using expect within your handler) or when you notice a false negative despite exceptions being thrown.

Default

false

test()

test: (parameters) => Promisable<void>

Defined in: src/index.ts:151

test is a function that runs your test assertions. This function receives one destructured parameter: fetch, which is equivalent to globalThis.fetch but with the first parameter omitted.

Parameters

parameters
fetch

(customInit?) => FetchReturnType<NextResponseJsonType>

Returns

Promisable<void>