Skip to main content
Vouch provides built-in simulation flags and mocking utilities so you can fully exercise your integration logic — including all fraud flag branches and identity outcomes — without submitting real identity documents or initiating live bank transfers. This guide covers every technique you need to build a reliable, well-tested integration.

Testing Fraud Detection

Use the simulateVpn and simulateImpossibleTravel flags on vouch.fraud.assess() and vouch.escrow.assess() to force specific risk outcomes in your development environment.
To produce an AMBER result, use a freshly created test user ID (so the account has no verification history) together with a high transaction amount. This typically triggers identity_not_verified and nudges the score into the 40–69 range.
Always test all three fraud flag branches (GREEN, AMBER, RED) in your integration test suite. Your payment flow has distinct code paths for each — leaving any branch untested means you may only discover bugs in production.
Pay particular attention to the AMBER path. Step-up verification involves multiple async calls (hold transaction → prompt re-verification → re-assess), and this is the branch most commonly broken by integration regressions.

Testing Identity Verification

In development, vouch.identity.submitVerification() still processes files through the full pipeline — you can pass any image file and observe the response. Use distinct externalUserId values for each test case so the results don’t overwrite one another.
To mock device fingerprinting during tests (for example, to test device_mismatch signal handling), set globalThis.MOCK_FINGERPRINT to a fixed string before initialising the SDK. This prevents the fingerprinting library from querying real browser APIs, which are unavailable in Node test environments.
Use a different MOCK_FINGERPRINT value in a second test to simulate a device change and verify that your device_mismatch handling code is reached.

Unit Testing Tips

For unit tests where you want zero network calls, mock the entire vouch-sdk module. The mock below stubs every method used across the KYC, fraud, and escrow flows with sensible defaults that you can override per test.
Override the default mock return value within individual tests to simulate failure paths:
Keep your unit test mocks in sync with the actual SDK response shapes shown in the Fraud Assessment and KYC Flow guides. Stale mock data is one of the most common causes of tests that pass locally but fail against the live API.