Heal

Basic test example

Scaffold a Playwright test with a Heal fixture, hooks, and a first healClick step.

Good news, you generally don't have to care about this. Just ask the Heal autopilot!

In case you need it, this example shows how to extend Playwright’s test with a heal fixture that creates one Heal instance per test, tears it down afterward, and uses heal.getPage() to call the heal agent.

import { test as base } from '@playwright/test';
import { Heal } from '@heal-dev/heal-cli/sdk';

type HealFixture = {
  heal: Heal;
};

const test = base.extend<HealFixture>({
  heal: async ({}, use) => {
    // Initialize the Heal instance
    const heal = await Heal.init({
      headless: true,
    });
    await use(heal);
    await heal.close();
  },
});

test.beforeEach(async ({ heal }) => {
  // per test setup if needed
});
test.afterEach(async ({ heal }) => {
  // per test cleanup if needed
});

test('my first test', async ({ heal }) => {
  // Get the page and agent
  const { page, agent } = await heal.getPage();

  await agent.healClick('The login button');
});

For more API detail, see the SDK reference.