healenium-js
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Healenium-JS 🧪

A self-healing decorator for Playwright UI tests — inspired by Healenium. Automatically heals broken selectors using fuzzy matching and maintains fallback history.

✨ Features

  • ✅ Self-heals selectors using fuzzy text-matching
  • 📖 Tracks fallback usage and selector history
  • 🧩 Decorator-based usage via @Healenium
  • 🔁 Automatically updates fallback selectors
  • 🧰 Written in TypeScript, ready for npm publishing

📦 Installation

npm install healenium-js

🚀 Usage

1. Decorate Failing Selector Method

import { Healenium } from 'healenium-js';

class MyTests {
  page: Page;

  constructor(page: Page) {
    this.page = page;
  }

  @Healenium('#non-existent-button')
  async clickMissingButton() {
    await this.page.click('#non-existent-button');
  }
}

2. Run Your Playwright Test

npx playwright test

3. View Fallback Data

  • fallback-selectors.json — latest healed selectors
  • 📚 selector-history.json — all past fallback selectors

🧠 How It Works

  • When a selector fails, the plugin:
    1. Extracts its text
    2. Uses Levenshtein distance to find a similar element
    3. Generates a new selector and stores it
    4. Re-runs the test using the new selector

🧪 Example Test

import { test as base } from '@playwright/test';
import { Healenium } from 'healenium-js';

class Demo {
  page: Page;
  constructor(page: Page) {
    this.page = page;
  }

  @Healenium('#broken-selector')
  async triggerHealer() {
    await this.page.click('#broken-selector');
  }
}

base('Healenium demo', async ({ page }) => {
  const t = new Demo(page);
  await page.goto('https://example.com');
  await t.triggerHealer();
});

📜 License

MIT © [Your Name]

Package Sidebar

Install

npm i healenium-js

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

12.2 kB

Total Files

8

Last publish

Collaborators

  • narutonpm