You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Defined in: [src/index.ts:285](https://github.com/Xunnamius/next-test-api-route-handler/blob/85e69e8c9f0f5d099e62128bf945b508df618dd6/src/index.ts#L285)
12
+
13
+
Uses Next's internal `apiResolver` (for Pages Router) or an
14
+
`AppRouteRouteModule` instance (for App Router) to execute api route handlers
Defined in: [src/index.ts:119](https://github.com/Xunnamius/next-test-api-route-handler/blob/85e69e8c9f0f5d099e62128bf945b508df618dd6/src/index.ts#L119)
10
10
11
11
## Extended by
12
12
@@ -23,6 +23,8 @@
23
23
24
24
> `optional`**rejectOnHandlerError**: `boolean`
25
25
26
+
Defined in: [src/index.ts:132](https://github.com/Xunnamius/next-test-api-route-handler/blob/85e69e8c9f0f5d099e62128bf945b508df618dd6/src/index.ts#L132)
27
+
26
28
If `false`, errors thrown from within a handler are kicked up to Next.js's
27
29
resolver to deal with, which is what would happen in production. If `true`,
28
30
the [testApiHandler](../functions/testApiHandler.md) function will reject immediately instead.
@@ -38,30 +40,26 @@ negative despite exceptions being thrown.
Defined in: [src/index.ts:138](https://github.com/Xunnamius/next-test-api-route-handler/blob/85e69e8c9f0f5d099e62128bf945b508df618dd6/src/index.ts#L138)
50
50
51
51
`test` is a function that runs your test assertions. This function receives
52
52
one destructured parameter: `fetch`, which is equivalent to
53
53
`globalThis.fetch` but with the first parameter omitted.
Defined in: [src/index.ts:149](https://github.com/Xunnamius/next-test-api-route-handler/blob/85e69e8c9f0f5d099e62128bf945b508df618dd6/src/index.ts#L149)
10
+
9
11
The parameters expected by `testApiHandler` when using `appHandler`.
10
12
11
13
## Extends
@@ -22,32 +24,30 @@ The parameters expected by `testApiHandler` when using `appHandler`.
Defined in: [src/index.ts:158](https://github.com/Xunnamius/next-test-api-route-handler/blob/85e69e8c9f0f5d099e62128bf945b508df618dd6/src/index.ts#L158)
28
+
25
29
The actual App Router route handler under test. It should be an object
26
30
containing one or more async functions named for valid HTTP methods and/or
Defined in: [src/index.ts:169](https://github.com/Xunnamius/next-test-api-route-handler/blob/85e69e8c9f0f5d099e62128bf945b508df618dd6/src/index.ts#L169)
Defined in: [src/index.ts:179](https://github.com/Xunnamius/next-test-api-route-handler/blob/85e69e8c9f0f5d099e62128bf945b508df618dd6/src/index.ts#L179)
50
+
51
51
`params` is passed directly to the handler and represents processed dynamic
52
52
routes. This should not be confused with query string parsing, which is
53
53
handled by `Request` automatically.
@@ -56,15 +56,13 @@ handled by `Request` automatically.
56
56
params.id = 'some-id' }`. This is useful for quickly setting many params at
Defined in: [src/index.ts:189](https://github.com/Xunnamius/next-test-api-route-handler/blob/85e69e8c9f0f5d099e62128bf945b508df618dd6/src/index.ts#L189)
68
66
69
67
A function that receives `params`, an object representing "processed"
70
68
dynamic route parameters. Modifications to `params` are passed directly to
@@ -76,22 +74,22 @@ is handled by `Request` automatically.
Defined in: [src/index.ts:132](https://github.com/Xunnamius/next-test-api-route-handler/blob/85e69e8c9f0f5d099e62128bf945b508df618dd6/src/index.ts#L132)
92
+
95
93
If `false`, errors thrown from within a handler are kicked up to Next.js's
96
94
resolver to deal with, which is what would happen in production. If `true`,
97
95
the [testApiHandler](../functions/testApiHandler.md) function will reject immediately instead.
Defined in: [src/index.ts:201](https://github.com/Xunnamius/next-test-api-route-handler/blob/85e69e8c9f0f5d099e62128bf945b508df618dd6/src/index.ts#L201)
123
119
124
120
A function that receives a `NextRequest` object and returns a `Request`
125
121
instance. Use this function to edit the request _before_ it's injected
Defined in: [src/index.ts:214](https://github.com/Xunnamius/next-test-api-route-handler/blob/85e69e8c9f0f5d099e62128bf945b508df618dd6/src/index.ts#L214)
149
145
150
146
A function that receives the `Response` object returned from `appHandler`
151
147
and returns a `Response` instance. Use this function to edit the response
Defined in: [src/index.ts:138](https://github.com/Xunnamius/next-test-api-route-handler/blob/85e69e8c9f0f5d099e62128bf945b508df618dd6/src/index.ts#L138)
176
172
177
173
`test` is a function that runs your test assertions. This function receives
178
174
one destructured parameter: `fetch`, which is equivalent to
179
175
`globalThis.fetch` but with the first parameter omitted.
Defined in: [src/index.ts:219](https://github.com/Xunnamius/next-test-api-route-handler/blob/85e69e8c9f0f5d099e62128bf945b508df618dd6/src/index.ts#L219)
200
+
205
201
`url: 'your-url'` is shorthand for `requestPatcher: (request) => new
0 commit comments