UK Fake Address Generator for Postcode Tests

Use a synthetic United Kingdom address fixture for form and import tests. Check the UK postcode layout and local address fields.

Generator settings

Advanced settings

Preview

Example
  • 16 Example Lane

Test fixture

{
  "building": "Flat 4, Example House",
  "street": "16 Example Lane",
  "city": "London",
  "postalCode": "sw1a  1aa",
  "country": "GB"
}

Address format

A UK postcode has an outward part and a three-character inward part. Store the full postcode as text and check that a paste with repeated spaces or lowercase letters reaches the same canonical form if the application accepts those variants. Preserve a single space when displaying the normalized sample on the address summary.

Use a separate flat or building field to test a non-numeric premise. UK addresses can use a building name, a street or locality line and a post town. Create one case with a flat and another with a named building only. On a compact screen, check that the postcode and post town remain visible beside the edit button.

Form and import tests

Check how the product displays a manual address after a postcode lookup returns more than one premise. In an integration fixture, use a stub response for the result list and make sure clicking one choice fills the intended lines. For a lookup failure, verify that any entered fields stay populated and the customer can continue with manual entry.

A checkout may make county optional. Leave that field blank in one fixture, and add it to a second record for an import consumed by older systems. If a county is supplied, compare the preview and saved payload to ensure the app has not copied the post town into the county slot during normalization.

Fixture assertions

The sample uses a familiar London postcode and a synthetic street label. A pattern can recognize the shape of the postcode used in the example. Actual lookup requires an authoritative test integration. Use the linked Royal Mail service to understand lookup behavior and configure a service-approved fixture when testing a provider’s address verification.

The JavaScript checks normalization of one outward pattern used by the London example. Intentionally include a different postcode layout in your own fixtures, since the complete UK postcode grammar has several outward forms. Assert that your form can render both the result from lookup and a record typed directly into the address lines.

JavaScript test example

const fixture = {
  "building": "Flat 4, Example House",
  "street": "16 Example Lane",
  "city": "London",
  "postalCode": "sw1a  1aa",
  "country": "GB"
};
const postcode = fixture.postalCode.toUpperCase().replace(/\s+/g, ' ');
if (!/^SW\d[A-Z] \d[A-Z]{2}$/.test(postcode) || !(postcode === 'SW1A 1AA')) {
  throw new Error("Address fixture failed");
}

Related generators