EveryRole

Slow E2E tests? Split the journey at the wait

Slow E2E tests have three causes. Two are fixed inside the test. The third is your app’s own slow work, and the answer is to split the journey at the wait.

Slow E2E tests come in three kinds, and only two can be fixed inside the test. Repeated set-up and fixed pauses are waste: remove them. The third kind is a journey that waits on your app’s own slow work, like an export or a render. No test trick makes that faster. Split the journey at the wait: a quick first part that ends when the app has started the work, and a second part that runs the whole thing to the end, in the background.

That way the slow journey is still tested, on every deploy, and nobody waits for it.

Three kinds of slow E2E test and the fix for each: repeated set-up (sign in once), fixed pauses (wait for the thing on the page), and the app's own slow work (split the journey at the wait)
The first two are waste in the test. The third is how long your app takes, and no test can change it.

Slow E2E tests: first, find out which kind you have

Before changing anything, time each test over its last several runs and take the middle value. One slow run is noise. A test that is slow every time is telling you something.

Then open the slowest one and read where the time goes:

  • Set-up. Every test logs in through the form, creates the same starting data, clicks through the same three pages. Individually small, together a large part of the run.
  • Fixed pauses. wait 5 seconds after every click, set once by someone on a slow day.
  • The app working. The test presses a button and then, correctly, waits for the app to finish something that takes a long time.

The first two are covered in our post on E2E tests in CI: sign in once per kind of user and reuse the session, wait for a condition on the page, run in parallel with separate data. This post is about the third, because the advice above doesn’t touch it. Running four ten-minute waits side by side still takes ten minutes.

Long-running E2E tests are waiting on the app

Some features are slow by nature. An export of a year of records. A report built from many queries. A file being converted. An answer written by an AI model. One of the apps we test makes videos, and a video takes minutes to make however good the test is.

A journey through such a feature has a shape: a quick part, a long wait, a quick part. All the test’s time is in the middle, where it does nothing.

The tempting fixes are both wrong. Skipping the test leaves your slowest, most complicated feature as the one thing nobody checks. Putting it in the deploy check as it is makes every deploy wait for it, and sooner or later someone removes it “for now”.

Split the journey at the wait

Cut it into two tests at the moment the app takes over.

One journey with a long wait in the middle, split in two: part one runs in the deploy's check and ends when the list shows the export in progress; part two runs the whole journey in the background and ends on the finished file
Part one answers within seconds. Part two answers when the app is done, and holds nobody up.

Part one ends when the app has started. Log in, fill the form, press the button, and check that the app took the job: the new export is in the list, marked as in progress, and still there after a reload. This is quick, so it belongs in the check that runs on every deploy.

It has to end on something real. “No error appeared after pressing Export” is a hollow pass. “The list has one more row, with this run’s name on it” is a result. A lot can break in this half: the button, the form, the permission, the request that queues the work.

Part two is the whole journey. The same steps, then the wait, then the finished result opened and looked at: the file downloads, is the type its button names, and isn’t empty. It runs right after the deploy’s check, in the background, or on the schedule. When it fails it alerts like any other test. It just doesn’t make anyone wait.

Part two repeats part one on purpose. It is the real journey, start to finish. Part one is the early warning.

Give the wait its own deadline

The quick reaction to a long wait is to raise the E2E test timeout for everything. Then a test that is simply broken takes fifteen minutes to say so.

Keep the general timeout short. Give the one long wait its own deadline, based on what you measured: if the export takes about four minutes, wait up to eight for it and say plainly when that passed.

Two more details make the wait trustworthy:

  • Poll for a state, not for time. Look for the row to change from “in progress” to “ready”. The test ends the moment it does.
  • Tell “still working” from “stuck”. If the app shows progress and it is still moving at the deadline, that is a slow day. If nothing on the page has changed for minutes, that is a failure. Report them differently.

Make the work smaller, not fake

You can often shorten the wait honestly. Export one small record set. Convert the shortest file the feature accepts. Ask for the smallest thing that still goes through every stage.

What we wouldn’t do in an end-to-end test is replace the slow part with a stand-in that answers at once. That is a fine unit test. It is no longer the journey: the queue, the worker and the storage in between are exactly what breaks.

Don’t run it twice

Retrying a failed test is cheap when the test only looked at pages. A slow journey usually sent something real: it started an export, a render, a job that costs you compute and maybe money. Running it again “to be sure” starts a second one.

So a test that really sent something should not be retried automatically. If it fails, report it, with what was on the screen. Retry only what failed before it sent anything. The same rule keeps a flaky test from hiding behind a second attempt.

How EveryRole handles slow journeys

EveryRole measures how long each test takes: the middle value of its last runs, never a guess, and a test that has never run has no time yet. A test measured as long (more than ten minutes, which in practice means it waits on your app’s own slow work) never runs in a deploy’s check.

After a deploy, a run has two parts. The check comes first: the quick tests and the page checks. The long tests run right after it, in the background, as a second part of the same run, and their results join that run’s page. They never hold back the next deploy’s check. The daily run and a run by hand include everything.

And it follows the last rule above. A test that really sent something to your app is never run a second time because it failed. A test that sent nothing yet is tried once more, after a failure or a problem on our side, and a pass on that second try says so on the result.

What it doesn’t do today is cut one journey in two for you. It classes whole tests by their measured time. Where the app takes over is something you know about your own app, and it is where the split belongs.

Keep reading

Deploys and CI

E2E tests in CI without slowing every merge

Run E2E tests in CI as two sets. A few journeys block the merge, the full suite reports after it. How to choose the blocking set and keep it quick.

6 min read

Deploys and CI

Run tests after every deploy, not every night

Post-deployment testing: the deploy starts the tests on the live address, and the result names that deploy. The set-up, and what a nightly run is still for.

5 min read

Deploys and CI

How to test a vibe-coded app before users do

How to test a vibe-coded app: from the outside, as each kind of user, on the running app. The agent says what changed, and something else has to prove it works.

7 min read