Testing KYC and Identity Verification Flows Without Real Identities

Test data · November 2026 · 9 min read

How to test UK onboarding and identity checks properly: provider sandboxes, mocking the provider, synthetic applicants, and the edge cases that find real bugs.

Know Your Customer (KYC) and identity verification flows are among the hardest parts of a UK product to test. They call external providers, they handle the most sensitive data you hold, and the interesting paths (a mismatch, a referral, a failed document check) are exactly the ones real customers rarely trigger on demand. This guide covers how to test them properly without putting real identities into your test environments.

What a UK identity check usually involves

A typical onboarding check for a regulated UK business (a bank, a payments firm, a lender, a crypto exchange, an accountant or estate agent under the Money Laundering Regulations) combines several of these:

Your product turns those outcomes into a decision (approve, reject, or send to a person for manual review), and that decision logic is what your tests most need to cover.

Why you should not test with real identities

It is tempting to run the flow with a colleague's details, or with records from production. Do not:

  • The data is about as sensitive as it gets. A passport scan, a date of birth and an address history are everything needed to impersonate someone. If a test environment leaks, it is a reportable breach involving exactly the data you most need to protect.
  • Real checks have real effects. An electronic identity check can leave a footprint on the person's credit file. Repeating it dozens of times on a colleague's details for a test suite is not something they agreed to.
  • Real people do not fail on demand. Your colleague passes every time. The rejection, referral and sanctions-hit paths need inputs that fail, and you cannot ask a real person to have a mismatched address.

The general principle is set out in using real customer data in test environments. For identity data it applies with full force.

Layer 1: provider sandboxes

Every serious identity verification provider offers a sandbox, and the sandbox is where the integration should be tested. Sandboxes typically work in one of two ways:

  • Magic values. Specific names, dates of birth, document numbers or test images that force a particular result: approve, reject, refer, sanctions hit.
  • Configurable outcomes. A sandbox setting or request parameter that chooses the result regardless of the input.

Either way, read the provider's testing documentation and build your suite around the values it lists. They are the only inputs guaranteed to produce each outcome reliably. Keep a table in your test code mapping each documented value to the outcome it should produce, and assert on your product's decision, not just on the provider's response.

Layer 2: mocking the provider

Sandboxes are slow, rate-limited and occasionally down, and they only return what the provider decided to model. For the bulk of your tests, mock the provider at the HTTP boundary:


// The provider's response, reduced to what your decision logic reads.
const outcomes = {
  approve: { identity: 'match', addressYears: 5, document: 'pass', sanctions: 'clear' },
  thinFile: { identity: 'partial', addressYears: 0, document: 'pass', sanctions: 'clear' },
  documentFail: { identity: 'match', addressYears: 5, document: 'fail', sanctions: 'clear' },
  sanctionsHit: { identity: 'match', addressYears: 5, document: 'pass', sanctions: 'potential_match' }
};

test.each(Object.entries(outcomes))('%s routes to the right decision', async (name, response) => {
  mockKycProvider.respondWith(response);
  const decision = await onboard(syntheticApplicant());
  expect(decision).toMatchSnapshot(name);
});

This is where the coverage comes from: every combination your decision logic distinguishes, in milliseconds, with no network. The technique, with a full working example for an address lookup service, is in mocking an address lookup API in tests.

Two things to keep the mocks honest:

  • Record real sandbox responses and build the mocks from them, so the shape matches what the provider actually sends.
  • Run a small sandbox suite on a schedule (nightly, say) against the real sandbox, so you find out when the provider changes its response format.

Layer 3: synthetic applicants

Your own forms, validation and storage need applicant data too: a name, a date of birth, a current address, previous addresses, a phone number and an email. Generate them:

  • Addresses must be structurally valid UK addresses, or your own postcode validation will reject them before the provider is even called. The UK address generator gives addresses on real postcode districts and post towns that are never live delivery points, and the REST API returns them as JSON for seed scripts.
  • Address history needs several addresses per applicant with plausible move-in dates. Generate a list per applicant and derive the dates from the applicant's age.
  • Names should include the awkward cases your form must accept: hyphenated surnames, apostrophes, very long names, a single given name.
  • Phone numbers should come from the ranges Ofcom reserves for fiction, so a test can never text a real person. These are listed in the UK telephone numbering plan explained.
  • Bank details for account verification should be generated to pass format checks, as described in UK sort codes, account numbers and IBANs for test data.
  • Company details for business onboarding should use a generated company name and a checksum-valid VAT number.

The test data generator produces a complete fictional applicant (name, address, postcode, phone number) in one step.

Test cases worth having

Beyond the happy path, these are the cases that tend to find real bugs:

  • Thin file. A young applicant or a recent arrival with no credit history. Your flow should refer or ask for documents, not reject outright.
  • Recent move. Under three years at the current address, so the previous address matters. Check your form collects it and sends it.
  • Address format variance. A flat number, a house name with no number, a Scottish or Northern Irish postcode. Checks often fail on formatting, not on identity. The causes are in why your address form rejects valid UK addresses.
  • Name variance. The name on the document differs slightly from the name typed (a middle name, a married name, an accent).
  • Potential sanctions match. Must route to a person, never auto-reject or auto-approve.
  • Provider timeout or error. The applicant should see a sensible message, and the application should be resumable rather than lost.
  • Duplicate applicant. The same person applying twice, or two people at one address.
  • Data retention. After a rejection or a withdrawn application, check that the documents and check results are deleted or retained exactly as your retention policy says.

Identity verification is regulated, and the decision rules belong to your compliance team. The test suite's job is to prove that the product does what those rules say, for every outcome, without a real identity ever entering a test environment.

More guides