Docs/Why runs are fast
#

Why runs are fast

Why Cofactor test runs finish in minutes. Each test gets its own sandbox copy of your app with the browser running beside it, on Cofactor's own MicroVM platform, so tests run in parallel without contention. Applies to E2E tests and Playwright suites.

Cofactor runs each test on its own copy of your app and runs many copies at once, so a suite takes about as long as its longest tests instead of the sum of all of them. This page explains the four design choices behind that.

Where does the browser run?

The browser runs inside the sandbox, on the same virtual machine as your app. A sandbox (also called a test environment) is a live copy of your application with its own data and logins. See Environments.

When a test loads a page, the request goes from the browser to your app inside that one machine. It does not cross the internet.

Cofactor's agent still decides what each step does. It runs outside the sandbox and controls the browser over a secure connection.

Your own Playwright tests run the same way. Playwright, Chromium and your app share one machine for each test. See Bring your own suite.

What infrastructure runs the sandboxes?

Each sandbox is a full virtual machine, and Cofactor runs them on its own MicroVM platform. Cofactor does the slow work of building and seeding once and reuses the result for every test.

  1. Cofactor builds and seeds your app once for each version and environment.
  2. It saves the running result as a snapshot.
  3. Each claim restores its own copy from that snapshot.

For test runs, the snapshot also includes a browser that is already running. A copy comes up with your app, its data and a browser ready, and the test does not wait for any of them to start.

Cofactor also warms host capacity when a suite starts, so copies have somewhere ready to run.

Only the first claim of a new version waits for the build. See Build from GitHub and Build from a pushed image.

Do tests slow each other down?

Each test gets its own copy of the app, so tests do not compete for anything inside it.

  • Data. Each copy has its own database, seed data and test logins. A test can create, change and delete records without affecting another test.
  • Outside services. Email, sign-in and other outside services are replaced by stand-ins that run inside the copy, so tests do not share a third-party account.
  • CPU and memory. Each copy is a machine with the vCPUs and memory that your sandbox definition sets in resources. A new copy starts only when its host has room for it.

Copies run on shared hosts, and the hosts are the one resource that tests have in common. For Playwright suites, each run reserves hosts for your organization.

How many tests run at once?

Every test in a run starts on its own copy, and Cofactor spreads them across copies for you. You do not assign tests to machines.

How many copies run at once depends on your plan.

PlanSandboxes at once
Free5
Starter10
Scale100

A test that is over the limit waits for a free slot and then starts. It does not fail. See Plans and limits.

Two things set the order inside a run.

  • A named suite runs the tests in a layer in parallel and the layers in order, so a sign-in test can finish first. See Suites and schedules.
  • A Playwright suite puts each independent test on its own copy. Tests in a serial describe block share one copy, because they depend on each other.

Go deeper

Advanced

Where the browser does not run in the sandbox, and the Playwright parallel limit.

Browser placement. A test uses the browser in its sandbox when the sandbox is built from GitHub, or from an image pushed with Cofactor's browser included. Tests on a live environment, and tests that need Firefox, WebKit, stealth mode or browser extensions, use a browser that Cofactor runs outside the sandbox.

Playwright parallel limit. Playwright suites run up to 8 tests at once by default, or your plan's limit if it is lower. To run more at once, contact us.