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

Reference / @getenginex/sdk/testing / MockFetchOptions

MockFetchOptions ​

Options of createMockFetch.

Properties ​

routes? ​

optional routes?: Record<string, MockHandler>

Overrides or adds routes by "METHOD /api/v1/path". A :name segment matches any value, which arrives in req.params.name (e.g. 'GET /api/v1/deposits/:depositId'). An exact route wins over one with parameters; between equals, a handler here wins over the default. Routes without a handler (default or here) return 404 NOT_FOUND.

Example ​

ts
createMockFetch({ routes: { 'GET /api/v1/config': () => fail(503, 'UNAVAILABLE') } })

twoFactorRequired? ​

optional twoFactorRequired?: boolean

Simulates an account with 2FA enabled: POST /auth/login without twoFactorCode returns { status: '2fa_required' }; with any non-empty code, it authenticates normally. Default: false.


user? ​

optional user?: object

Simulated identity used in the access token claims and in auth responses.

operatorId? ​

optional operatorId?: string

Operator id. Default: 'mock-operator-1'.

userId? ​

optional userId?: string

User id. Default: 'mock-user-1'.


withdrawalOtp? ​

optional withdrawalOtp?: boolean

Simulates an operator that requires an OTP on withdrawal (withdraw_money flow in config.otp.flows): withdrawals.request returns { status: 'otp_required' } and withdrawals.confirmOtp with any non-empty code submits the withdrawal. Default: false (withdrawal created immediately).