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-broad-utils

v1.1.0

Published

Utility functions for broad Playwright testing.

Readme

Playwright Broad Utils - Setup Guide

This guide walks you through setting up Playwright in your project and using the playwright-broad-utils package for broad testing.


Prerequisites

  • Node.js (v16 or higher recommended).
  • Basic understanding of Playwright and web testing.

Step 1: Install Playwright

To use Playwright, first install it in your project:

npm install -D @playwright/test

Step 2: Install Playwright Utils

Install the playwright-broad-utils package:

npm install -D playwright-broad-utils

Step 3: Configure Playwright

If you haven’t already, set up a Playwright configuration file. Create playwright.config.ts:

import { defineConfig } from "@playwright/test";

export default defineConfig({
  testDir: "./tests",
  use: {
    baseURL: "http://localhost:4200",
    headless: true,
  },
});

Step 4: Create a Test File

Write your tests in the tests directory. For example, create tests/home.spec.ts:

import { test } from "@playwright/test";
import {
  captureWebSocketMessages,
  checkAllExternalLinks,
  checkButtonsVisibilityAndAriaLabel,
  checkHeadingsVisibility,
  checkImagesVisibility,
} from "playwright-broad-utils";

test("@Home", async ({ page }) => {
  await page.goto("/home");

  const urlFilter = /localhost:4201/; // WebSocket URL and port we want to capture.
  // Start capturing WebSocket messages
  const wsMessages = await captureWebSocketMessages(page, {
    urlFilter,
    timeout: 10000,
  });

  await checkAllExternalLinks(page);
  await checkButtonsVisibilityAndAriaLabel(page);
  await checkHeadingsVisibility(page);
  await checkImagesVisibility(page);
});

Step 5: Run Your Tests

Run your Playwright tests with:

npx playwright test

Utility Function Details

checkButtonsVisibilityAndAriaLabel(page: Page)

Checks if all buttons are visible and have an aria-label attribute.

checkHeadingsVisibility(page: Page)

Ensures all headings (<h1> to <h6>) are visible on the page.

checkImagesVisibility(page: Page)

Verifies all images are visible and checks for alt attributes for accessibility.

checkAllExternalLinks(page: Page)

Verifies all external links open in a new tab.

captureWebSocketMessages(page: Page, options?: { urlFilter?: string | RegExp; timeout?: number; })

You can filter to catch all WS messages on a domain (/localhost/) or only those matching a specific URL:PORT i.e. /localhost:4201/.


Troubleshooting

Multiple Versions of Playwright

Ensure playwright-broad-utils uses the same version of Playwright as your project. To check:

npm ls @playwright/test

If there are multiple versions, deduplicate:

npm dedupe

Test Directory Configuration

Ensure your test files are in the directory specified in playwright.config.ts (testDir).

TypeScript Paths

If you encounter module resolution errors, update your tsconfig.json:

{
  "compilerOptions": {
    "paths": {
      "@playwright/test": ["./node_modules/@playwright/test"]
    }
  }
}

Additional Notes

  • This package relies on Playwright's peer dependencies. Ensure @playwright/test is installed in your project.
  • Restart your development environment if TypeScript errors persist after installation.