How Adresskoll is tested

Adresskoll is an address register with statistics on residents, move-ins, cars and companies for housing co-ops and villa areas. It handles sensitive information, so the test strategy starts from what must never go wrong, not from what is easy to test. This page is the method. The code and the data stay private.

Open the live site (opens in a new tab)

Risk map

Risks are ranked by the harm if they happen, and each one has a named place in the suite where it is checked.

  1. Sensitive details shown to the wrong visitor. Surnames, registration numbers, villa house numbers and photos must be masked on the server for anyone who is not logged in. Checked by unit and API tests on the masking rules and by E2E tests that log in and out as a visitor.
  2. Wrong person matches. The same person can appear in several sources with name variants. A bad merge silently mixes two people. Checked by unit tests for every matching level, including a mother and daughter with the same name.
  3. Importers that stop reading correctly. The sources change their markup without notice. Checked by running the real import functions against saved HTML fixtures, never against live sites.
  4. Tests touching production data. Every test runs against an in-memory database, a temporary photo directory and a mocked LinkedIn. Any other outgoing request fails the test.
  5. Layout that breaks on a phone. Grids, charts and dialogs are covered by screenshot baselines on mobile and desktop, and one spec opens every view at 390 px and fails on horizontal scroll.

The test pyramid

Most checks sit low, where they are fast and exact. A browser is used only for what a browser is needed for. Each layer links to the risks from the map above that it guards against.

  1. Visual baselines 118 screenshots

    Mobile at 390 px and desktop at 1280 px for layouts that DOM assertions do not catch. Fonts are forced to the same files on every machine, and dates are frozen, so the images do not drift.

    Guards against

  2. End-to-end tests 34 files in Chromium

    One file per view, because each file starts its own server and database. Logic that already has a unit test is only exercised in the browser as a flow that proves the wiring.

    Guards against

  3. Unit and API tests 140 files, about 1,400 test cases

    Plain node:test with an in-memory SQLite database. Logic such as masking, matching and statistics is kept free of I/O so it can be tested without a server. Routes are tested against the real app on a free port. Coverage thresholds fail the build if they drop.

    Guards against

CI on every pull request: types, lint, formatting and coverage in one job, the full E2E suite in another

The test architecture: each layer, how much runs there and the risks it guards against.

Bugs that became tests

The rule is that every bug fix ships with a test that fails without it. Three from the history:

Flakiness and run time

Flakiness is treated as a bug in the test. It is prevented by rule where possible and fixed when it still shows up.

A test-code excerpt

The hook that makes the “zero console errors” rule automatic. It runs after every E2E test, so a new test inherits it for free. Names are translated and simplified.

// Runs after every E2E test in the file.
afterEach(() => {
  if (!activeHarness) return;
  const { blockedRequests, problems } = activeHarness;

  // Empty the lists so an error only fails the test that caused it.
  const blocked = blockedRequests.splice(0);
  const errors = problems.splice(0);

  assert.deepEqual(blocked, [], 'External requests were blocked');
  assert.deepEqual(errors, [], 'Console or page errors during the test');
});
Back to the projects