How to acceptance-test n8n workflows in a disposable Docker lab

Unit tests can't prove an n8n workflow imports and runs. A pinned, isolated Docker lab with synthetic data and database assertions can. Here's how we build one.

By StackSignal ·

Testing the JavaScript inside your Code nodes is useful, and you should do it. It still leaves the questions that actually break production unanswered. Does this exact JSON import into my n8n version? Do the node parameters mean what I think they mean? Does the workflow behave correctly when two webhooks arrive at once?

The only way to answer those questions is to run the real files in a real n8n. This article describes the lab we built to acceptance-test the Reliable Automation Kit before release. You can build the same thing for your own workflows in an afternoon.

The rules of the lab

  1. Pin every version. We used the n8nio/n8n:2.20.8 and postgres:16.16-alpine images. A result is only meaningful for the versions it ran on, so we say exactly which ones.
  2. Isolate it completely. A private Docker network, no published host ports, and temporary database storage. Nothing in the lab can reach a real account, and nothing outside can reach the lab.
  3. Synthetic everything. Fake credentials, a mock API that serves fixture data, and a mock alert receiver that records what would have been sent. No real notifications, no billing calls.
  4. Import the exact files you ship. Don't import a hand-edited copy. Import the distributed JSON first, and only then install the lab-specific variant (local URLs, test credentials) alongside it.
  5. Assert on outcomes, not on "it ran". Check the rows the workflow wrote, the alerts the mock received and the number of times a side effect happened.

The shape of it

A minimal Compose file has three services on one internal network:

services:
  postgres:
    image: postgres:16.16-alpine
    tmpfs: [/var/lib/postgresql/data]
    networks: [lab]
  n8n:
    image: n8nio/n8n:2.20.8
    depends_on: [postgres]
    networks: [lab]
  mock:
    image: node:22-alpine
    command: node /mock/server.js
    networks: [lab]
networks:
  lab:
    internal: true

internal: true is what guarantees isolation. Containers can talk to each other, but not to the internet. A Node script on the host drives everything through docker compose exec, so no ports need to be published at all.

What the runner does

  1. Start the stack and wait for n8n's health endpoint.
  2. Import each workflow file with the n8n CLI and record a SHA-256 hash of every file, so the evidence says exactly which bytes were tested.
  3. Configure test copies: point HTTP nodes at the mock, attach synthetic credentials, and wire up workflow IDs (an error workflow, a sub-workflow).
  4. Trigger each scenario. Use real schedules where timing matters (we let a one-minute failure generator run on its actual schedule), and webhook triggers where you need deterministic starts.
  5. Assert against PostgreSQL, the n8n execution history and the mock's recorded requests.
  6. Tear down with docker compose down -v, so nothing persists.

Scenarios worth testing

These are the checks that caught real issues for us:

  • Concurrency. Fire several copies of the same webhook in parallel (Promise.all, not a loop) and assert that the side effect happened exactly once. In our lab, 5 concurrent deliveries of one event produced 1 side effect, and the ledger recorded the other 4 as duplicates.
  • Error classes. Generate failures of each kind (401, 429, timeout, 5xx, bad data). Assert that each is stored with the right class, and that a repeated failure doesn't send a second alert.
  • Silence. Feed the mock API execution histories for a healthy, a stale, a failing and a never-run workflow, and assert the watchdog's verdict on each.
  • Safety defaults. For anything that can take action, such as retries, assert that dry-run mode made zero calls to the mock's action endpoint.

Things the lab found that unit tests never would

  • In n8n 2.20.8, the CLI import of a single workflow file without an ID can be rejected, while import:workflow --separate accepts it.
  • A published workflow couldn't execute an unpublished sub-workflow, or an unpublished configured error workflow. Both errors reproduced in the lab, and the install guide now says to publish them first.
  • The Postgres node accepted array-valued query parameters. A key containing a comma, an apostrophe and Unicode round-tripped as a single value. That's exactly the input that breaks naive comma-separated parameter lists.

Each of these looks small, and each would have been a support ticket.

Report it honestly

Publish what you tested and what you didn't. Our validation report lists the pinned versions, workflow file hashes, results, and the release boundary. n8n Cloud, other versions, external task runners and live automatic recovery all need their own runs. Customers trust a narrow claim they can verify more than a broad one they can't.

If you run n8n for clients, the free Reliability Audit is a quick first pass on any instance. The lab is how you prove changes before they ship.

Related