npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

playwright-automation-library

v1.0.0

Published

Reusable Playwright library for automation testing

Readme

playwright-automation-library

Reusable Playwright npm library for automation testing — companion to cypress-automation-library and infy-mcp-playwright.

Features

  • Action helperssafeClick, fillField, login, getByTestId, and more
  • Fixturesauto fixture with all helpers bound to page
  • Utilities — selectors, wait helpers, API helpers, test data generators
  • Config helper — easy Playwright config setup via registerConfig
  • TypeScript — full type definitions included

Installation

npm install playwright-automation-library @playwright/test
npx playwright install

Quick Start

Option 1: Use the auto fixture (recommended)

// tests/login.spec.ts
import { test, expect } from 'playwright-automation-library';

test('logs in successfully', async ({ auto }) => {
  await auto.login('[email protected]', 'password123');
  await expect(auto.getByTestId('dashboard')).toBeVisible();
});

Option 2: Import helpers directly

import { test, expect } from '@playwright/test';
import { safeClick, fillField, login, getByTestId } from 'playwright-automation-library';

test('fills a form safely', async ({ page }) => {
  await page.goto('/contact');
  await fillField(page, '[name="email"]', '[email protected]');
  await safeClick(page, '[type="submit"]');
  await expect(getByTestId(page, 'success-message')).toBeVisible();
});

Configure Playwright (optional)

// playwright.config.ts
import { defineConfig } from '@playwright/test';
import { registerConfig } from 'playwright-automation-library';

export default defineConfig(
  registerConfig(
    {
      testDir: './tests',
      fullyParallel: true,
    },
    {
      baseURL: 'https://your-app.com',
      viewport: { width: 1280, height: 720 },
      actionTimeout: 10000,
    }
  )
);

Action Helpers

| Helper | Description | |--------|-------------| | safeClick(page, selector) | Click only after element is visible | | fillField(page, selector, value) | Clear and fill an input | | clearAndType(page, selector, text) | Clear field then type | | waitForVisible(page, selector) | Wait until element is visible | | waitForHidden(page, selector) | Wait until element is hidden | | getByTestId(page, testId) | Select by data-testid | | getByRole(page, role, options?) | Select by ARIA role | | getByLabel(page, label) | Find input by label text | | getByPlaceholder(page, placeholder) | Find input by placeholder | | login(page, user, pass, options?) | Reusable login flow | | uploadFile(page, selector, filePath) | Upload a file | | selectDropdown(page, selector, value) | Select dropdown value | | scrollToElement(page, selector) | Scroll element into view | | getTableRow(page, row) | Get table row by index | | getTableCell(page, row, col) | Get table cell by row/column | | withinIframe(page, selector, callback) | Run actions inside iframe | | hoverElement(page, selector) | Hover over element | | checkCheckbox(page, selector) | Check a checkbox | | uncheckCheckbox(page, selector) | Uncheck a checkbox | | assertText(page, selector, text) | Assert element contains text | | assertUrl(page, path) | Assert URL contains path | | screenshotNamed(page, name) | Take named screenshot | | mockApiResponse(page, method, url, response) | Mock API response | | waitForApi(page, url) | Wait for API response | | dragAndDrop(page, source, target) | Drag and drop elements | | closeModal(page, selector?) | Close modal/dialog | | typeSlow(page, selector, text, delay?) | Slow typing for animations | | doubleClickElement(page, selector) | Double click element | | forceClick(page, selector) | Force click element |

Utilities

import {
  byTestId,
  byRole,
  byPlaceholder,
  buildSelector,
  waitForStable,
  generateEmail,
  generatePhone,
  generatePassword,
  formatDate,
  setAuthToken,
  apiRequest,
  mockApiResponse,
} from 'playwright-automation-library';

// Selector helpers
const btn = byTestId('submit-btn');
const emailInput = byPlaceholder('Enter email');

// Test data
const email = generateEmail('user');
const phone = generatePhone();
const date = formatDate(7); // 7 days from now

// API request with auth token
setAuthToken('your-jwt-token');
const response = await apiRequest(request, 'GET', '/api/users');

Development

npm install
npm run build
npm run lint

Publish to npm

npm login
npm pack --dry-run
npm publish

Push to GitHub

git init
git add .
git commit -m "Initial commit: Playwright automation library"
git remote add origin https://github.com/sujeet0414/playwright-automation-library.git
git push -u origin main

License

MIT