Reference / @getenginex/sdk/testing / MockFetchOptions
MockFetchOptions
Options of createMockFetch.
Properties
routes?
optionalroutes?: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
createMockFetch({ routes: { 'GET /api/v1/config': () => fail(503, 'UNAVAILABLE') } })twoFactorRequired?
optionaltwoFactorRequired?: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?
optionaluser?:object
Simulated identity used in the access token claims and in auth responses.
operatorId?
optionaloperatorId?:string
Operator id. Default: 'mock-operator-1'.
userId?
optionaluserId?:string
User id. Default: 'mock-user-1'.
withdrawalOtp?
optionalwithdrawalOtp?: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).