Warning
This package is experimental and not meant for production. Use e2e instead.
touchpress runs e2e tests for mobile apps on the Playwright test runner. It drives a booted simulator or emulator through agent-device.
import { expect, test } from 'touchpress';
test('the right credentials land on the profile', async ({ device }) => {
await device.getByTestId('sign-in-link').tap();
await device.getByRole('text-field', { name: 'Email' }).fill('rob@example.com');
await device.getByTestId('password').fill('hunter2', { secret: true });
await device.getByRole('button', { name: 'Sign in' }).tap();
await expect(device.getByTestId('signing-in')).toBeVisible();
await expect(device.getByTestId('profile-email')).toHaveText('rob@example.com', { exact: true });
});
test('open sign in with AI', async ({ device }) => {
test.setTimeout(180_000);
await device.act('Open the sign-in screen');
await expect(device.getByTestId('login')).toBeVisible();
});pnpm add -D touchpress @playwright/test// playwright.config.ts
import { defineConfig } from '@playwright/test';
import type { TouchpressOptions } from 'touchpress';
export default defineConfig<TouchpressOptions>({
testDir: 'e2e',
workers: 1,
use: {
app: 'com.example.app',
readyWhen: { testId: 'home' },
},
projects: [
{ name: 'ios', use: { platform: 'ios', deviceName: 'iPhone 17 Pro Max' } },
{ name: 'android', use: { platform: 'android', deviceName: 'Pixel 7 API 34' } },
],
});Set app to your app's bundle ID or package name and readyWhen to a locator visible once it has loaded.
Install your app on a booted simulator or emulator, save your tests in e2e/, then run:
npx playwright test --project=ios
npx playwright test --project=androidSee apps/e2e for an Expo app with tests and setup instructions.
MIT