Skip to content

Commit

Permalink
release: 4.0.8 [skip ci]
Browse files Browse the repository at this point in the history
### [4.0.8](v4.0.7...v4.0.8) (2024-06-10)

#### ⚙️ Build system

* Revert conventional-changelog-cli update ([9967120](9967120))
* Update documentation generator ([43eec53](43eec53))
  • Loading branch information
Xunnamius committed Jun 10, 2024
1 parent 9967120 commit 466aeb7
Show file tree
Hide file tree
Showing 11 changed files with 801 additions and 844 deletions.
1,044 changes: 527 additions & 517 deletions CHANGELOG.md

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion docs/.nojekyll

This file was deleted.

76 changes: 7 additions & 69 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,82 +1,20 @@
next-test-api-route-handler
**next-test-api-route-handler****Docs**

# next-test-api-route-handler
***

## Table of contents
# next-test-api-route-handler

### Interfaces
## Interfaces

- [NtarhInit](interfaces/NtarhInit.md)
- [NtarhInitAppRouter](interfaces/NtarhInitAppRouter.md)
- [NtarhInitPagesRouter](interfaces/NtarhInitPagesRouter.md)

### Type Aliases

- [FetchReturnType](README.md#fetchreturntype)
- [Promisable](README.md#promisable)

### Functions

- [testApiHandler](README.md#testapihandler)

## Type Aliases

### FetchReturnType

Ƭ **FetchReturnType**\<`NextResponseJsonType`\>: `Promise`\<`Omit`\<`Response`, ``"json"``\> & \{ `cookies`: `ReturnType`\<`parse`\>[] ; `json`: (...`args`: `Parameters`\<`Response`[``"json"``]\>) => `Promise`\<`NextResponseJsonType`\> }\>

#### Type parameters

| Name |
| :------ |
| `NextResponseJsonType` |

#### Defined in

[index.ts:100](https://github.com/Xunnamius/next-test-api-route-handler/blob/b7621d6b938246e73d656a1f9516def892b70ed0/src/index.ts#L100)

___

### Promisable

Ƭ **Promisable**\<`Promised`\>: `Promised` \| `Promise`\<`Promised`\>

#### Type parameters

| Name |
| :------ |
| `Promised` |

#### Defined in

[index.ts:95](https://github.com/Xunnamius/next-test-api-route-handler/blob/b7621d6b938246e73d656a1f9516def892b70ed0/src/index.ts#L95)
- [FetchReturnType](type-aliases/FetchReturnType.md)
- [Promisable](type-aliases/Promisable.md)

## Functions

### testApiHandler

**testApiHandler**\<`NextResponseJsonType`\>(`«destructured»`): `Promise`\<`void`\>

Uses Next's internal `apiResolver` (for Pages Router) or an
`AppRouteRouteModule` instance (for App Router) to execute api route handlers
in a Next-like testing environment.

#### Type parameters

| Name | Type |
| :------ | :------ |
| `NextResponseJsonType` | `any` |

#### Parameters

| Name | Type |
| :------ | :------ |
| `«destructured»` | [`NtarhInitAppRouter`](interfaces/NtarhInitAppRouter.md)\<`NextResponseJsonType`\> \| [`NtarhInitPagesRouter`](interfaces/NtarhInitPagesRouter.md)\<`NextResponseJsonType`\> |

#### Returns

`Promise`\<`void`\>

#### Defined in

[index.ts:273](https://github.com/Xunnamius/next-test-api-route-handler/blob/b7621d6b938246e73d656a1f9516def892b70ed0/src/index.ts#L273)
- [testApiHandler](functions/testApiHandler.md)
29 changes: 29 additions & 0 deletions docs/functions/testApiHandler.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[**next-test-api-route-handler**](../README.md)**Docs**

***

[next-test-api-route-handler](../README.md) / testApiHandler

# Function: testApiHandler()

> **testApiHandler**\<`NextResponseJsonType`\>(`__namedParameters`): `Promise`\<`void`\>
Uses Next's internal `apiResolver` (for Pages Router) or an
`AppRouteRouteModule` instance (for App Router) to execute api route handlers
in a Next-like testing environment.

## Type parameters

**NextResponseJsonType** = `any`

## Parameters

**\_\_namedParameters**: [`NtarhInitAppRouter`](../interfaces/NtarhInitAppRouter.md)\<`NextResponseJsonType`\> \| [`NtarhInitPagesRouter`](../interfaces/NtarhInitPagesRouter.md)\<`NextResponseJsonType`\>

## Returns

`Promise`\<`void`\>

## Source

[index.ts:273](https://github.com/Xunnamius/next-test-api-route-handler/blob/43eec5385cb48f619257324a2fe1b54d29748ff1/src/index.ts#L273)
63 changes: 25 additions & 38 deletions docs/interfaces/NtarhInit.md
Original file line number Diff line number Diff line change
@@ -1,78 +1,65 @@
[next-test-api-route-handler](../README.md) / NtarhInit

# Interface: NtarhInit\<NextResponseJsonType\>

## Type parameters
[**next-test-api-route-handler**](../README.md)**Docs**

| Name | Type |
| :------ | :------ |
| `NextResponseJsonType` | `unknown` |
***

## Hierarchy

- **`NtarhInit`**
[next-test-api-route-handler](../README.md) / NtarhInit

[`NtarhInitAppRouter`](NtarhInitAppRouter.md)
# Interface: NtarhInit\<NextResponseJsonType\>

[`NtarhInitPagesRouter`](NtarhInitPagesRouter.md)
## Extended by

## Table of contents
- [`NtarhInitAppRouter`](NtarhInitAppRouter.md)
- [`NtarhInitPagesRouter`](NtarhInitPagesRouter.md)

### Properties
## Type parameters

- [rejectOnHandlerError](NtarhInit.md#rejectonhandlererror)
- [test](NtarhInit.md#test)
**NextResponseJsonType** = `unknown`

## Properties

### rejectOnHandlerError
### rejectOnHandlerError?

`Optional` **rejectOnHandlerError**: `boolean`
> `optional` **rejectOnHandlerError**: `boolean`
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](../README.md#testapihandler) function will reject immediately instead.
the [testApiHandler](../functions/testApiHandler.md) 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`**
#### Default

```ts
false
```

#### Defined in
#### Source

[index.ts:123](https://github.com/Xunnamius/next-test-api-route-handler/blob/b7621d6b938246e73d656a1f9516def892b70ed0/src/index.ts#L123)
[index.ts:123](https://github.com/Xunnamius/next-test-api-route-handler/blob/43eec5385cb48f619257324a2fe1b54d29748ff1/src/index.ts#L123)

___
***

### test
### test()

**test**: (`parameters`: \{ `fetch`: (`customInit?`: `RequestInit`) => [`FetchReturnType`](../README.md#fetchreturntype)\<`NextResponseJsonType`\> }) => [`Promisable`](../README.md#promisable)\<`void`\>
> **test**: (`parameters`) => [`Promisable`](../type-aliases/Promisable.md)\<`void`\>
`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.

#### Type declaration

▸ (`parameters`): [`Promisable`](../README.md#promisable)\<`void`\>
#### Parameters

##### Parameters
**parameters**

| Name | Type |
| :------ | :------ |
| `parameters` | `Object` |
| `parameters.fetch` | (`customInit?`: `RequestInit`) => [`FetchReturnType`](../README.md#fetchreturntype)\<`NextResponseJsonType`\> |
**parameters.fetch**

##### Returns
#### Returns

[`Promisable`](../README.md#promisable)\<`void`\>
[`Promisable`](../type-aliases/Promisable.md)\<`void`\>

#### Defined in
#### Source

[index.ts:129](https://github.com/Xunnamius/next-test-api-route-handler/blob/b7621d6b938246e73d656a1f9516def892b70ed0/src/index.ts#L129)
[index.ts:129](https://github.com/Xunnamius/next-test-api-route-handler/blob/43eec5385cb48f619257324a2fe1b54d29748ff1/src/index.ts#L129)
Loading

0 comments on commit 466aeb7

Please sign in to comment.