This version (v0.7) has not been published to npm yet.
Skip to content

Reference / @getenginex/sdk-igaming/testing / createIgamingRoutes

createIgamingRoutes() ​

createIgamingRoutes(): Record<string, MockHandler>

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, 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>

Example ​

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

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