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

@rafael_dev/playwright-api-framework

v1.0.2

Published

Reusable Playwright API Testing Framework with HttpHandler, Contract Validation, and Logging

Readme

Playwright API Testing Framework

npm version TypeScript Playwright Package Manager License

An extensible, type-safe API Testing Framework and reusable NPM library built on top of Playwright's APIRequestContext.

It offers custom test fixtures, centralized HTTP request handling, automatic request logging, and OpenAPI contract validation out-of-the-box.


Background & Context

This project originated as part of my Programming 5 university course. After completing the coursework, I refactored and modularized the architecture into a standalone TypeScript library (@rafael_dev/playwright-api-framework) to be reused across different API testing projects. For example, my Software Development 5 university course has a testing module using this library. Go check it out here

Disclaimer: Even if this project is working properly, I strongly recommend to NOT use it in a production environment.


Key Features

  • NPM Package Distribution: Pre-compiled TypeScript library (dist/) exported with full type definitions (.d.ts).
  • Custom Playwright Fixtures (createApiTest): Injects a pre-configured http handler directly into Playwright tests.
  • Robust HttpHandler: Wraps APIRequestContext to simplify request execution, response parsing, and error reporting.
  • Contract Validation: Built-in ContractValidator leveraging AJV and OpenAPI (Swagger) specs to validate schema compliance.
  • Automated Request Logging: Formatted logging of URLs, method, status code, payload, headers, and responses for quick debugging.
  • Data Generation & Factories: Integrated with @faker-js/faker for dynamic data generation and factory patterns (UserFactory).

Usage Guide

Option 1: Integrating as a Library Package

You can import core abstractions (createApiTest, HttpHandler, ContractValidator, RequestLogger) directly into your own project:

pnpm add -D @rafael_dev/playwright-api-framework @playwright/test

Example Test in your Project:

import { createApiTest, HttpHandler } from '@rafael_dev/playwright-api-framework';

const test = createApiTest();

test('GET /users - Check Status', async ({ http }) => {
  const response = await http.get('/users');
  expect(response.response.status()).toBe(200);
});

Repository Structure

├── api/                  # Endpoint-specific API wrappers & DTO definitions
│   └── users/            # Example user API endpoints & DTOs
├── helpers/              # Framework core helpers & utilities
│   ├── contract/         # AJV & OpenAPI schema contract validator
│   ├── factory/          # Test data factories (Faker.js)
│   ├── fixtures/         # Custom Playwright test fixtures
│   ├── handler/          # Central HttpHandler abstraction
│   └── log/              # Request & response loggers
├── tests/                # Test cases organized by domain entities
├── index.ts              # Library entry point exporting core abstractions
├── openapi.yaml          # OpenAPI specification for contract tests
├── playwright.config.ts  # Playwright configuration
└── package.json          # Package manifest (@rafael_dev/playwright-api-framework)