---
url: >-
  https://game-engine-io.github.io/enginex-frontend-sdk/reference/api/@getenginex/sdk/testing/functions/fail.md
---
[Reference](../../../../index.md) / [@getenginex/sdk/testing](../index.md) / fail

# fail()

> **fail**(`status`, `code`, `message?`, `details?`): `Response`

Error response in the gateway format (`{ success: false, error }`), ready for a
[MockHandler](../type-aliases/MockHandler.md) handler. Without `message`, it uses the `code` itself.

## Parameters

### status

`number`

### code

`string`

### message?

`string`

### details?

`Record`<`string`, `unknown`>

## Returns

`Response`

## Example

```ts
createMockFetch({ routes: { 'POST /api/v1/auth/login': () => fail(401, 'INVALID_CREDENTIALS') } })
```
