blog.dopana

Back

Have you ever felt exhausted writing dozens of lines of code just to test a simple user flow? Or frustrated when the UI changes and all your tests break? e2e is a next-generation end-to-end testing framework that uses AI to solve these problems.

In this post, we’ll explore how e2e works and why it might change the way you write tests.

Why e2e?#

Imagine you’re testing a signup flow. With traditional frameworks like Playwright or Cypress, you’d write:

await page.click('button[name="signup"]');
await page.fill('input[name="email"]', 'test@example.com');
await page.fill('input[name="password"]', 'password123');
await page.click('button[type="submit"]');
await expect(page.locator('.welcome-message')).toBeVisible();
typescript

If the button name changes or the layout shifts, your test fails. You have to manually fix the code.

With e2e, you just tell the AI:

await agent.act('sign up with email {email}', {
  params: { email: 'test@example.com' }
});
await agent.assert('the welcome screen is showing');
typescript

The AI automatically figures out how to perform the action and checks the result. When the UI changes, the AI adapts automatically.

What is e2e?#

e2e is an open-source end-to-end testing framework for web and mobile apps, built to keep up with the speed we ship software today. Key features:

  • AI-driven: Uses AI models to perform actions and check results
  • Deterministic: Also supports traditional APIs with locators and assertions
  • Hybrid: You can mix both approaches in the same test
  • Cross-platform: Runs tests on web (Chromium), iOS, and Android

How e2e Works#

e2e has three main components:

Test FileTargetsWeb / iOS / AndroidAgent Stepsagent.act / agent.assertCacheReplay verified stepsEnginesPlaywright for Webagent-device for MobileAI ModelExecute ActionsJudge ScreenNo Model CallsFast & Cheap

Targets#

Each test runs once per target:

  • Web: Chromium, Firefox, Safari via Playwright
  • Mobile: iOS simulators and Android emulators via agent-device
  • Custom: You can write your own engine for other platforms

Agent Steps#

  • agent.act: Complete a goal in natural language
  • agent.assert: Check a condition on the screen
  • agent.waitFor: Wait for a condition to become true
  • agent.extract: Extract structured data from the screen

Cache#

Verified act steps are recorded and replayed from cache without AI model calls. This helps:

  • Reduce token costs
  • Speed up test runs
  • Preserve old actions when the app hasn’t changed

Getting Started with e2e#

Quick Setup#

npx e2e init
bash

This command will:

  • Create e2e.config.ts configuration file
  • Create an example test
  • Add dependencies
  • Set up your coding agent

Web Configuration#

e2e.config.ts
import type { E2EConfig } from 'e2e';
import { web } from '@e2e-dev/web';
import { gateway } from 'ai';

export default {
  agents: { default: { model: gateway('openai/gpt-6-luna-fast') } },
  targets: [{ engine: web(), app: { url: 'http://localhost:3000' } }],
} satisfies E2EConfig;
typescript

First Test#

tests/example.e2e.ts
import { test } from '@e2e-dev/web';
import { expect } from 'e2e';

test('app opens', async ({ app, browser }) => {
  await app.open('/');
  await expect(browser.locator('body')).toBeVisible();
});
typescript

Run the test:

npx e2e run
bash

Writing Tests with AI#

Agent Actions#

import { test } from '@e2e-dev/web';
import { expect } from 'e2e';

test('a visitor signs up for a trial', async ({ app, agent, screen }) => {
  await app.open('/');

  await agent.act('sign up for a free trial as {name} with email {email}', {
    params: { name: 'Ada Lovelace', email: 'ada@example.test' },
  });

  await agent.assert('the welcome screen greets Ada by name');
  await expect(screen.getByRole('status')).toContainText('trial');
});
typescript

Mixing Deterministic and AI#

test('todos survive a filter round-trip', async ({ app, agent, screen }) => {
  await app.open('/todos');

  // AI handles complex interaction
  await agent.act('add todos "Buy milk" and "Walk the dog", complete the first');
  await agent.assert('only one todo remains open');

  // Deterministic check for exact value
  await screen.getByRole('tab', 'Done').tap();
  await expect(screen.getByTestId('todo')).toHaveCount(1);
});
typescript

Combining Both Approaches#

e2e lets you mix agent steps with deterministic APIs in the same test:

  • Agent steps: When you don’t know the exact action needed
  • Deterministic APIs: When you need to check exact values or know the locator
// Agent handles complex flow
await agent.act('complete checkout with the test card');

// Deterministic check for exact result
await expect(screen.getByText('Order #12345')).toBeVisible();
typescript

Benefits of e2e#

Time Back#

Write a goal instead of a script of selectors and waits. When the UI changes, the agent adapts, so you spend less time writing and fixing tests.

Less Risk#

Cover more of the flows your users depend on, on web and mobile, and catch regressions before they reach production.

Cheap Runs#

Verified agent.act steps replay from a cache with no model calls. Test more flows without the token bill or a slow CI.

Authentication and Secrets#

e2e has built-in support for secrets:

import { credentials } from 'e2e';

const member = credentials.user('member');
await agent.act('Sign in', {
  params: { username: member.username, password: member.password },
});
typescript

Secrets are redacted from model input for security.

Mobile Testing#

e2e also supports iOS and Android:

e2e.config.ts
import { mobile } from '@e2e-dev/mobile';

export default {
  targets: [{
    name: 'ios',
    engine: mobile({ platform: 'ios' }),
    app: { bundleId: 'com.yourapp' }
  }],
  workers: 1,
} satisfies E2EConfig;
typescript
tests/mobile.e2e.ts
import { test } from '@e2e-dev/mobile';

test('the agent opens General', async ({ agent, app, device }) => {
  await app.open();
  await agent.act('open {section} settings', { params: { section: 'General' } });

  await agent.assert('the General settings screen is showing');
  await expect(device.locator('role=NavigationBar id=General')).toBeVisible();
});
typescript

Coding Agents#

e2e is designed to work with coding agents like Claude, Cursor, Codex. After setup, you can:

  • “Add a test for checkout”
  • “Why did this run fail?”
  • “Debug this test”

The agent automatically reads the skill and performs the necessary actions.

Conclusion#

e2e represents a significant leap forward in end-to-end testing. By combining AI with deterministic APIs, it allows you to:

  • Write tests faster
  • Maintain tests easier
  • Cover more user flows
  • Run tests on multiple platforms

If you’re looking for a modern approach to testing your applications, e2e is worth trying.

References#