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

# createIgamingRoutes()

> **createIgamingRoutes**(): `Record`<`string`, [`MockHandler`](../../../sdk/testing/type-aliases/MockHandler.md)>

Creates the iGaming mock routes, in the `MockFetchOptions.routes` format of the `createMockFetch` from
`@getenginex/sdk/testing` (`"METHOD /api/v1/path"` → handler). Each call returns new routes,
with its own in-memory state: create one per mock. Prefer [withIgamingRoutes](withIgamingRoutes.md), which
already does the merge with your options.

Covers the whole `casino`: fixed catalog (7 games in 3 categories and 3 providers, with the gateway's filters,
ordering and pagination), `GAME_NOT_FOUND` for unknown ids, a launch that returns
a fictitious URL (`https://games.mock.local/play/...?token=...`) and opens an active session
(ending the previous one), history and winners ranking.

Covers the whole `bonus`: three campaigns (opt-in with redemption by the player, automatic free spins and
the `BEMVINDO` promo code one), cursor pagination, opt-in, claim and promo code redemption with in-memory
state, and the same `Idempotency-Key` repeating the first response (without duplicating): on opt-in and
claim like the gateway's idempotency middleware (a different body is `PAYLOAD_MISMATCH`); on
promo code redemption, which does not go through the middleware, only the header is required and the same key returns
the same participation. Errors like the gateway's: `BONUS_NOT_FOUND`, `BONUS_ALREADY_CLAIMED`, `ALREADY_EXISTS`,
`BONUS_NOT_ELIGIBLE` (with HTTP 500, as the gateway still returns it) and `INVALID_ARGUMENT` for ids
that are not UUIDs.

Covers the `sportsbook`: `GET /first/session` (requires login) returns a fictitious FIRST URL
(`https://first.mock.local/sportsbook?operatorToken=...`) valid for 24 h.

Covers the `missions`: four fixed missions (`GET /missions`, paginated by the envelope's `meta`, with
`target_games` `null` and epoch dates) and the player's progress (`GET /my/missions`, in `data.missions`).

Covers `loyalty`: `GET /loyalty` (a `gold` player with 1500 points and benefits as JSON text) and
`POST /loyalty/redeem` (HTTP 200, deducts from the balance, `INSUFFICIENT_BALANCE` if points are short).

Covers the `referrals`: `GET /referrals` (code `MOCK123` and totals as a major-unit float, like the gateway),
`GET /referrals/history` (three referrals, paginated by `page`/`limit` inside `data`, with the
referee's email unmasked, as the gateway sends it) and `POST /referrals/register` (HTTP 201; only the code `BEMVINDO`
exists, the others answer `NOT_FOUND`).

All responses match the SDK schemas, even with `validation: 'strict'`.

## Returns

`Record`<`string`, [`MockHandler`](../../../sdk/testing/type-aliases/MockHandler.md)>

## Example

```ts
import { createMockFetch } from '@getenginex/sdk/testing'
import { createIgamingRoutes } from '@getenginex/sdk-igaming/testing'

const fetch = createMockFetch({ routes: { ...createIgamingRoutes(), ...myRoutes } })
```
