Skip to content

Commit d4f6936

Browse files
committed
release: [email protected] [skip ci]
## 🪄 Fixes - **src:** address incompatibility with next\@15.2 ([69525da][2]) <sup>see [#1129][3]</sup> ## ⚙️ Build System - **deps:** bump @whatwg-node/server from 0.9.66 to 0.9.70 ([1c11e5d][4]) [1]: https://github.com/Xunnamius/next-test-api-route-handler/compare/[email protected]@4.0.15 [2]: 69525da [3]: #1129 [4]: 1c11e5d
1 parent 85e69e8 commit d4f6936

File tree

104 files changed

+3839
-869
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+3839
-869
lines changed

CHANGELOG.md

Lines changed: 757 additions & 634 deletions
Large diffs are not rendered by default.

docs/README.md

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,11 @@
1-
**next-test-api-route-handler****Docs**
1+
**next-test-api-route-handler**
22

33
***
44

55
# next-test-api-route-handler
66

7-
## Interfaces
7+
## Modules
88

9-
- [NtarhInit](interfaces/NtarhInit.md)
10-
- [NtarhInitAppRouter](interfaces/NtarhInitAppRouter.md)
11-
- [NtarhInitPagesRouter](interfaces/NtarhInitPagesRouter.md)
12-
13-
## Type Aliases
14-
15-
- [FetchReturnType](type-aliases/FetchReturnType.md)
16-
- [Promisable](type-aliases/Promisable.md)
17-
18-
## Variables
19-
20-
- [$isPatched](variables/$isPatched.md)
21-
- [$originalGlobalFetch](variables/$originalGlobalFetch.md)
22-
23-
## Functions
24-
25-
- [testApiHandler](functions/testApiHandler.md)
9+
- [src](src/README.md)
10+
- [test/setup](test/setup/README.md)
11+
- [test/util](test/util/README.md)

docs/functions/testApiHandler.md

Lines changed: 0 additions & 29 deletions
This file was deleted.

docs/src/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[**next-test-api-route-handler**](../README.md)
2+
3+
***
4+
5+
[next-test-api-route-handler](../README.md) / src
6+
7+
# src
8+
9+
## Interfaces
10+
11+
- [NtarhInit](interfaces/NtarhInit.md)
12+
- [NtarhInitAppRouter](interfaces/NtarhInitAppRouter.md)
13+
- [NtarhInitPagesRouter](interfaces/NtarhInitPagesRouter.md)
14+
15+
## Functions
16+
17+
- [testApiHandler](functions/testApiHandler.md)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[**next-test-api-route-handler**](../../README.md)
2+
3+
***
4+
5+
[next-test-api-route-handler](../../README.md) / [src](../README.md) / testApiHandler
6+
7+
# Function: testApiHandler()
8+
9+
> **testApiHandler**\<`NextResponseJsonType`\>(`__namedParameters`): `Promise`\<`void`\>
10+
11+
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
15+
in a Next-like testing environment.
16+
17+
## Type Parameters
18+
19+
**NextResponseJsonType** = `any`
20+
21+
## Parameters
22+
23+
### \_\_namedParameters
24+
25+
[`NtarhInitAppRouter`](../interfaces/NtarhInitAppRouter.md)\<`NextResponseJsonType`\> | [`NtarhInitPagesRouter`](../interfaces/NtarhInitPagesRouter.md)\<`NextResponseJsonType`\>
26+
27+
## Returns
28+
29+
`Promise`\<`void`\>

docs/interfaces/NtarhInit.md renamed to docs/src/interfaces/NtarhInit.md

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
[**next-test-api-route-handler**](../README.md)**Docs**
1+
[**next-test-api-route-handler**](../../README.md)
22

33
***
44

5-
[next-test-api-route-handler](../README.md) / NtarhInit
5+
[next-test-api-route-handler](../../README.md) / [src](../README.md) / NtarhInit
66

77
# Interface: NtarhInit\<NextResponseJsonType\>
88

9-
**`Internal`**
9+
Defined in: [src/index.ts:119](https://github.com/Xunnamius/next-test-api-route-handler/blob/85e69e8c9f0f5d099e62128bf945b508df618dd6/src/index.ts#L119)
1010

1111
## Extended by
1212

@@ -23,6 +23,8 @@
2323

2424
> `optional` **rejectOnHandlerError**: `boolean`
2525
26+
Defined in: [src/index.ts:132](https://github.com/Xunnamius/next-test-api-route-handler/blob/85e69e8c9f0f5d099e62128bf945b508df618dd6/src/index.ts#L132)
27+
2628
If `false`, errors thrown from within a handler are kicked up to Next.js's
2729
resolver to deal with, which is what would happen in production. If `true`,
2830
the [testApiHandler](../functions/testApiHandler.md) function will reject immediately instead.
@@ -38,30 +40,26 @@ negative despite exceptions being thrown.
3840
false
3941
```
4042

41-
#### Defined in
42-
43-
[index.ts:137](https://github.com/Xunnamius/next-test-api-route-handler/blob/e773623b6be329996aafd723ed43e973bdc65aa6/src/index.ts#L137)
44-
4543
***
4644

4745
### test()
4846

49-
> **test**: (`parameters`) => [`Promisable`](../type-aliases/Promisable.md)\<`void`\>
47+
> **test**: (`parameters`) => `Promisable`\<`void`\>
48+
49+
Defined in: [src/index.ts:138](https://github.com/Xunnamius/next-test-api-route-handler/blob/85e69e8c9f0f5d099e62128bf945b508df618dd6/src/index.ts#L138)
5050

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

5555
#### Parameters
5656

57-
**parameters**
57+
##### parameters
5858

59-
**parameters.fetch**
59+
###### fetch
6060

61-
#### Returns
62-
63-
[`Promisable`](../type-aliases/Promisable.md)\<`void`\>
61+
(`customInit`?) => `FetchReturnType`\<`NextResponseJsonType`\>
6462

65-
#### Defined in
63+
#### Returns
6664

67-
[index.ts:143](https://github.com/Xunnamius/next-test-api-route-handler/blob/e773623b6be329996aafd723ed43e973bdc65aa6/src/index.ts#L143)
65+
`Promisable`\<`void`\>
Lines changed: 42 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
[**next-test-api-route-handler**](../README.md)**Docs**
1+
[**next-test-api-route-handler**](../../README.md)
22

33
***
44

5-
[next-test-api-route-handler](../README.md) / NtarhInitAppRouter
5+
[next-test-api-route-handler](../../README.md) / [src](../README.md) / NtarhInitAppRouter
66

77
# Interface: NtarhInitAppRouter\<NextResponseJsonType\>
88

9+
Defined in: [src/index.ts:149](https://github.com/Xunnamius/next-test-api-route-handler/blob/85e69e8c9f0f5d099e62128bf945b508df618dd6/src/index.ts#L149)
10+
911
The parameters expected by `testApiHandler` when using `appHandler`.
1012

1113
## Extends
@@ -22,32 +24,30 @@ The parameters expected by `testApiHandler` when using `appHandler`.
2224

2325
> **appHandler**: `Partial`\<`Omit`\<`AppRouteUserlandModule`, `"GET"` \| `"HEAD"` \| `"OPTIONS"` \| `"POST"` \| `"PUT"` \| `"DELETE"` \| `"PATCH"`\> & `object`\>
2426
27+
Defined in: [src/index.ts:158](https://github.com/Xunnamius/next-test-api-route-handler/blob/85e69e8c9f0f5d099e62128bf945b508df618dd6/src/index.ts#L158)
28+
2529
The actual App Router route handler under test. It should be an object
2630
containing one or more async functions named for valid HTTP methods and/or
2731
a valid configuration option. See [the Next.js
2832
documentation](https://nextjs.org/docs/app/building-your-application/routing/route-handlers)
2933
for details.
3034

31-
#### Defined in
32-
33-
[index.ts:163](https://github.com/Xunnamius/next-test-api-route-handler/blob/e773623b6be329996aafd723ed43e973bdc65aa6/src/index.ts#L163)
34-
3535
***
3636

3737
### pagesHandler?
3838

3939
> `optional` **pagesHandler**: `undefined`
4040
41-
#### Defined in
42-
43-
[index.ts:174](https://github.com/Xunnamius/next-test-api-route-handler/blob/e773623b6be329996aafd723ed43e973bdc65aa6/src/index.ts#L174)
41+
Defined in: [src/index.ts:169](https://github.com/Xunnamius/next-test-api-route-handler/blob/85e69e8c9f0f5d099e62128bf945b508df618dd6/src/index.ts#L169)
4442

4543
***
4644

4745
### params?
4846

4947
> `optional` **params**: `Record`\<`string`, `string` \| `string`[]\>
5048
49+
Defined in: [src/index.ts:179](https://github.com/Xunnamius/next-test-api-route-handler/blob/85e69e8c9f0f5d099e62128bf945b508df618dd6/src/index.ts#L179)
50+
5151
`params` is passed directly to the handler and represents processed dynamic
5252
routes. This should not be confused with query string parsing, which is
5353
handled by `Request` automatically.
@@ -56,15 +56,13 @@ handled by `Request` automatically.
5656
params.id = 'some-id' }`. This is useful for quickly setting many params at
5757
once.
5858

59-
#### Defined in
60-
61-
[index.ts:184](https://github.com/Xunnamius/next-test-api-route-handler/blob/e773623b6be329996aafd723ed43e973bdc65aa6/src/index.ts#L184)
62-
6359
***
6460

6561
### paramsPatcher()?
6662

67-
> `optional` **paramsPatcher**: (`params`) => [`Promisable`](../type-aliases/Promisable.md)\<`void` \| `Record`\<`string`, `string` \| `string`[]\>\>
63+
> `optional` **paramsPatcher**: (`params`) => `Promisable`\<`void` \| `Record`\<`string`, `string` \| `string`[]\>\>
64+
65+
Defined in: [src/index.ts:189](https://github.com/Xunnamius/next-test-api-route-handler/blob/85e69e8c9f0f5d099e62128bf945b508df618dd6/src/index.ts#L189)
6866

6967
A function that receives `params`, an object representing "processed"
7068
dynamic route parameters. Modifications to `params` are passed directly to
@@ -76,22 +74,22 @@ is handled by `Request` automatically.
7674

7775
#### Parameters
7876

79-
**params**: `Record`\<`string`, `string` \| `string`[]\>
80-
81-
#### Returns
77+
##### params
8278

83-
[`Promisable`](../type-aliases/Promisable.md)\<`void` \| `Record`\<`string`, `string` \| `string`[]\>\>
79+
`Record`\<`string`, `string` \| `string`[]\>
8480

85-
#### Defined in
81+
#### Returns
8682

87-
[index.ts:194](https://github.com/Xunnamius/next-test-api-route-handler/blob/e773623b6be329996aafd723ed43e973bdc65aa6/src/index.ts#L194)
83+
`Promisable`\<`void` \| `Record`\<`string`, `string` \| `string`[]\>\>
8884

8985
***
9086

9187
### rejectOnHandlerError?
9288

9389
> `optional` **rejectOnHandlerError**: `boolean`
9490
91+
Defined in: [src/index.ts:132](https://github.com/Xunnamius/next-test-api-route-handler/blob/85e69e8c9f0f5d099e62128bf945b508df618dd6/src/index.ts#L132)
92+
9593
If `false`, errors thrown from within a handler are kicked up to Next.js's
9694
resolver to deal with, which is what would happen in production. If `true`,
9795
the [testApiHandler](../functions/testApiHandler.md) function will reject immediately instead.
@@ -111,15 +109,13 @@ false
111109

112110
[`NtarhInit`](NtarhInit.md).[`rejectOnHandlerError`](NtarhInit.md#rejectonhandlererror)
113111

114-
#### Defined in
115-
116-
[index.ts:137](https://github.com/Xunnamius/next-test-api-route-handler/blob/e773623b6be329996aafd723ed43e973bdc65aa6/src/index.ts#L137)
117-
118112
***
119113

120114
### requestPatcher()?
121115

122-
> `optional` **requestPatcher**: (`request`) => [`Promisable`](../type-aliases/Promisable.md)\<`void` \| `Request`\>
116+
> `optional` **requestPatcher**: (`request`) => `Promisable`\<`void` \| `Request`\>
117+
118+
Defined in: [src/index.ts:201](https://github.com/Xunnamius/next-test-api-route-handler/blob/85e69e8c9f0f5d099e62128bf945b508df618dd6/src/index.ts#L201)
123119

124120
A function that receives a `NextRequest` object and returns a `Request`
125121
instance. Use this function to edit the request _before_ it's injected
@@ -131,21 +127,21 @@ NextRequest(returnedRequest, { ... })`.
131127

132128
#### Parameters
133129

134-
**request**: `NextRequest`
135-
136-
#### Returns
130+
##### request
137131

138-
[`Promisable`](../type-aliases/Promisable.md)\<`void` \| `Request`\>
132+
`NextRequest`
139133

140-
#### Defined in
134+
#### Returns
141135

142-
[index.ts:207](https://github.com/Xunnamius/next-test-api-route-handler/blob/e773623b6be329996aafd723ed43e973bdc65aa6/src/index.ts#L207)
136+
`Promisable`\<`void` \| `Request`\>
143137

144138
***
145139

146140
### responsePatcher()?
147141

148-
> `optional` **responsePatcher**: (`res`) => [`Promisable`](../type-aliases/Promisable.md)\<`void` \| `Response`\>
142+
> `optional` **responsePatcher**: (`res`) => `Promisable`\<`void` \| `Response`\>
143+
144+
Defined in: [src/index.ts:214](https://github.com/Xunnamius/next-test-api-route-handler/blob/85e69e8c9f0f5d099e62128bf945b508df618dd6/src/index.ts#L214)
149145

150146
A function that receives the `Response` object returned from `appHandler`
151147
and returns a `Response` instance. Use this function to edit the response
@@ -158,53 +154,49 @@ unhandled exception occurs _and_ `rejectOnHandlerError` is `true`.
158154

159155
#### Parameters
160156

161-
**res**: `Response`
162-
163-
#### Returns
157+
##### res
164158

165-
[`Promisable`](../type-aliases/Promisable.md)\<`void` \| `Response`\>
159+
`Response`
166160

167-
#### Defined in
161+
#### Returns
168162

169-
[index.ts:220](https://github.com/Xunnamius/next-test-api-route-handler/blob/e773623b6be329996aafd723ed43e973bdc65aa6/src/index.ts#L220)
163+
`Promisable`\<`void` \| `Response`\>
170164

171165
***
172166

173167
### test()
174168

175-
> **test**: (`parameters`) => [`Promisable`](../type-aliases/Promisable.md)\<`void`\>
169+
> **test**: (`parameters`) => `Promisable`\<`void`\>
170+
171+
Defined in: [src/index.ts:138](https://github.com/Xunnamius/next-test-api-route-handler/blob/85e69e8c9f0f5d099e62128bf945b508df618dd6/src/index.ts#L138)
176172

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

181177
#### Parameters
182178

183-
**parameters**
179+
##### parameters
180+
181+
###### fetch
184182

185-
**parameters.fetch**
183+
(`customInit`?) => `FetchReturnType`\<`NextResponseJsonType`\>
186184

187185
#### Returns
188186

189-
[`Promisable`](../type-aliases/Promisable.md)\<`void`\>
187+
`Promisable`\<`void`\>
190188

191189
#### Inherited from
192190

193191
[`NtarhInit`](NtarhInit.md).[`test`](NtarhInit.md#test)
194192

195-
#### Defined in
196-
197-
[index.ts:143](https://github.com/Xunnamius/next-test-api-route-handler/blob/e773623b6be329996aafd723ed43e973bdc65aa6/src/index.ts#L143)
198-
199193
***
200194

201195
### url?
202196

203197
> `optional` **url**: `string`
204198
199+
Defined in: [src/index.ts:219](https://github.com/Xunnamius/next-test-api-route-handler/blob/85e69e8c9f0f5d099e62128bf945b508df618dd6/src/index.ts#L219)
200+
205201
`url: 'your-url'` is shorthand for `requestPatcher: (request) => new
206202
NextRequest('your-url', request)`
207-
208-
#### Defined in
209-
210-
[index.ts:225](https://github.com/Xunnamius/next-test-api-route-handler/blob/e773623b6be329996aafd723ed43e973bdc65aa6/src/index.ts#L225)

0 commit comments

Comments
 (0)