Skip to main content

Using TestCafe for End to End Testing

Using TestCafe for End to End Testing

Key takeaways

  • TestCafe runs without WebDriver, which removes most of the setup friction.
  • Its automatic waiting cuts the flakiness that manual sleeps introduce.
  • End to end tests are expensive, so keep them to the journeys that matter.

TestCafe is a Node.js tool to automate end-to-end web testing.

TestCafe logo

What are End to End tests and why are they important?

End to End tests cover real journeys that your customers do, they are slower to execute but can be much more valuable comparing to unit and integration tests.

E2E testing cons:

  • slow and non-consistently passing tests
  • long configuration time
  • too long execution time – much longer than unit tests
  • debugging time is too high

What is TestCafe? History of TestCafe and how does it work?

TestCafe is a Node.js tool to automate end-to-end web testing and functional testing.

TestCafe was built on a URL-rewriting proxy called Hammerhead that emulates commands using the DOM API and injects JavaScript into the browser. Since TestCafe 3.0 it drives Chromium-based browsers through the native Chrome DevTools Protocol by default (native automation) and falls back to the proxy for Firefox, Safari and other browsers (testcafe.io, November 2026).

TestCafe supports multiple browsers without any browser drivers.

It runs every single test in its own isolated test environment to simulate new sessions.

Each test has finished being executed, it will lose the state (cookies, local storage etc) of the page and start from the beginning again.

Main TestCafe features:

  • Cross-browser testing
  • Open source
  • Easy setup/installation
  • UI End to End Tests
  • Builtin waits
  • Retry assertions
  • Uses standard CSS selectors to locate elements
  • Live mode: the --live (-L) flag reruns tests as you edit them; it replaced the separate TestCafe Live package
  • Remote browser/mobile testing: run tests in any browser (including mobile devices and cloud services)
  • No complex configuration required
  • Can control the speed at which tests are run
  • Concurrency: run multiple tests with same or different browsers at the same time
  • CI/CD integration
  • Screenshots testing
  • Supports TypeScript

Example of Test in TestCafe:

The test fills in the name field on TestCafe’s demo page, submits the form and checks the heading on the next page. Run it with npx testcafe chrome test.js.


import { Selector } from 'testcafe';

fixture `Getting Started`
    .page `https://devexpress.github.io/testcafe/example`;

test('My first test', async t => {
    await t
        .typeText('#developer-name', 'John Smith')
        .click('#submit-button')
        .expect(Selector('#article-header').innerText).eql('Thank you, John Smith!');
});

Frequently Asked Questions

What makes TestCafe easier to set up?

It runs without WebDriver, so there is no driver binary to match against your browser version. That removes most of the first-day friction.

How does it handle timing?

It waits automatically for elements and page loads, which removes the sleeps that cause most beginner flakiness.

How many end to end tests should I write?

Few. They are the slowest and most fragile layer, so keep them to the journeys that matter and cover the rest lower down.

Bogdan

Founder at LoadFocus

Bogdan builds and runs the tools this blog is about. He writes from what the products actually do in production, including the parts that break.

Weekly tips right in your inbox.

Don’t miss out on the latest testing tips and tricks, tools and news related to software testing.

Already +20,000 members in the list.

The Load Testing Platform with AI That Explains Your Results

Load test websites and APIs from 25 cloud regions, monitor page speed and uptime, and get AI analysis that explains your results in plain English.

Cloud load testing, website speed and API monitoring in one place.

Hi there! Can I share a cool thing I'm working on with you?

A software testing newsletter that sparks joy.

Our goal is to create helpful content for software developers and testers.

If you're not into it, you can unsubscribe instantly.