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

openapi-playwright-generator

v2.0.4

Published

Generate Playwright test files from OpenAPI specifications with boundary value testing

Downloads

24

Readme

OpenAPI Playwright Generator

Generate Playwright API tests from OpenAPI specifications with AI-powered business rule testing.

Installation

npm install -g openapi-playwright-generator

Configuration

1. Create .env file

สร้างไฟล์ .env ใน folder ที่จะรัน command:

# Gemini API (default)
GEMINI_API_KEY=your_gemini_api_key
GEMINI_MODEL=gemini-2.5-flash-preview-04-17

# หรือ OpenAI API
OPENAI_API_KEY=your_openai_api_key
OPENAI_MODEL=gpt-4o-mini

2. Get API Keys

| Provider | Get API Key | |----------|-------------| | Gemini | https://aistudio.google.com/apikey | | OpenAI | https://platform.openai.com/api-keys |

3. Available Models

Gemini:

  • gemini-2.5-flash-preview-04-17 (default)
  • gemini-2.0-flash
  • gemini-1.5-pro

OpenAI:

  • gpt-4o-mini (default)
  • gpt-4o
  • gpt-4-turbo

Usage

Option 1: Run Step by Step

Step 1: Generate Test Suite

openapi-test-gen gen:suite -i api-spec/booking-api.yaml --rules rules-base/booking-rules.yaml -o output/booking-suite.yaml --model gemini

Step 2: Generate Playwright Tests

openapi-test-gen gen:spec -s output/booking-suite.yaml -o generated/booking --name booking.spec.ts

Step 3: Run Playwright Tests

npx playwright test generated/booking/booking.spec.ts --ui

Option 2: Run All at Once

With Gemini:

openapi-test-gen gen:suite -i api-spec/booking-api.yaml --rules rules-base/booking-rules.yaml -o output/booking-suite.yaml --model gemini && openapi-test-gen gen:spec -s output/booking-suite.yaml -o generated/booking --name booking.spec.ts && npx playwright test generated/booking/booking.spec.ts --ui

With GPT:

openapi-test-gen gen:suite -i api-spec/booking-api.yaml --rules rules-base/booking-rules.yaml -o output/booking-suite.yaml --model gpt && openapi-test-gen gen:spec -s output/booking-suite.yaml -o generated/booking --name booking.spec.ts && npx playwright test generated/booking/booking.spec.ts --ui

Commands Reference

gen:suite

Generate test suite YAML from OpenAPI specification.

openapi-test-gen gen:suite [options]

| Option | Description | |--------|-------------| | -i, --input <path> | OpenAPI spec file (YAML/JSON) | | -o, --output <path> | Output suite file (YAML) | | --rules <path> | Business rules file | | --model <name> | AI model: gemini or gpt |

gen:spec

Generate Playwright test files from test suite.

openapi-test-gen gen:spec [options]

| Option | Description | |--------|-------------| | -s, --suite <path> | Suite YAML file | | -o, --output <dir> | Output directory | | --name <filename> | Test filename (default: suite-name.spec.ts) |


Examples

Booking API

# Gemini
openapi-test-gen gen:suite -i api-spec/booking-api.yaml --rules rules-base/booking-rules.yaml -o output/booking-suite.yaml --model gemini && openapi-test-gen gen:spec -s output/booking-suite.yaml -o generated/booking --name booking.spec.ts && npx playwright test generated/booking/booking.spec.ts --ui

# GPT
openapi-test-gen gen:suite -i api-spec/booking-api.yaml --rules rules-base/booking-rules.yaml -o output/booking-suite.yaml --model gpt && openapi-test-gen gen:spec -s output/booking-suite.yaml -o generated/booking --name booking.spec.ts && npx playwright test generated/booking/booking.spec.ts --ui

Library API

openapi-test-gen gen:suite -i api-spec/library-api.yaml --rules rules-base/library-rules.yaml -o output/library-suite.yaml --model gemini && openapi-test-gen gen:spec -s output/library-suite.yaml -o generated/library --name library.spec.ts && npx playwright test generated/library/library.spec.ts --ui

Order API

openapi-test-gen gen:suite -i api-spec/order-api.yaml --rules rules-base/order-rules.yaml -o output/order-suite.yaml --model gemini && openapi-test-gen gen:spec -s output/order-suite.yaml -o generated/order --name order.spec.ts && npx playwright test generated/order/order.spec.ts --ui

Business Rules Example

rules:
  - id: "vip_free_shipping"
    description: "VIP members get free shipping"
    if:
      all:
        - param: "memberType"
          op: "eq"
          value: "VIP"
    then:
      assert:
        all:
          - param: "shippingFee"
            op: "eq"
            value: 0

Supported Operators

| Operator | Description | |----------|-------------| | eq | Equal to | | neq | Not equal to | | gt | Greater than | | gte | Greater than or equal | | lt | Less than | | lte | Less than or equal | | in | Value in array |


Troubleshooting

API Error 401 Unauthorized

  • API key ไม่ถูกต้องหรือหมดอายุ
  • ตรวจสอบ .env file

API Error 404 Not Found

  • Model name ไม่ถูกต้อง
  • ลองเปลี่ยน model ใน .env

Command not found

npm uninstall -g openapi-playwright-generator
npm install -g openapi-playwright-generator

License

MIT