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

@definitely-fine/playwright

v0.1.1

Published

Playwright scenario helpers for definitely-fine browser-driven tests.

Readme

@definitely-fine/playwright

@definitely-fine/playwright helps Playwright tests activate definitely-fine scenarios in browser-driven flows.

It extends the core scenario builder with scenario header metadata plus helpers for creating browser contexts and pages that already send the active scenario id.

Installation

pnpm add -D @playwright/test @definitely-fine/playwright
pnpm add definitely-fine

What This Package Adds

createScenario() from this package builds on the core definitely-fine scenario builder and adds:

  • headerName
  • headers
  • createContext(browser, options?)
  • createPage(browser, options?)
flowchart LR
  subgraph P[Playwright worker process]
    P1[createScenario]
    P2[define rules and save scenario]
    P3[createContext or createPage]
  end

  subgraph B[Browser process]
    B1[request with scenario header]
  end

  subgraph A[Application server process]
    A1[@definitely-fine/nextjs or @definitely-fine/hono]
    A2[runWithRuntimeScenarioContext]
    A3[definitely-fine runtime]
  end

  subgraph S[Shared scenario storage]
    S1[(persisted scenario JSON)]
  end

  P1 --> P2 --> S1
  P2 --> P3
  P3 --> B1
  B1 --> A1 --> A2 --> A3
  A3 -- load active scenario --> S1

Example

import { test, expect } from "@playwright/test";
import { DEFINITELY_FINE_SCENARIO_HEADER } from "@definitely-fine/nextjs";
import { createScenario } from "@definitely-fine/playwright";

type DemoContract = {
  services: {
    counter: {
      incrementApi(): number;
      incrementAction(): number;
    };
  };
  functions: Record<string, never>;
  errors: Record<string, never>;
};

test("uses a scenario-backed browser context", async ({ browser }) => {
  const scenario = createScenario<DemoContract>({
    headerName: DEFINITELY_FINE_SCENARIO_HEADER,
  });

  scenario.service("counter").method("incrementApi").onCall(1).returns(10);
  await scenario.save();

  const context = await scenario.createContext(browser);

  try {
    const page = await context.newPage();

    await page.goto("/");
    await page
      .getByRole("button", { name: "Increment with API route" })
      .click();
    await expect(page.locator("#api-count")).toHaveText("10");
  } finally {
    await context.close();
    await scenario.dispose();
  }
});

Header Behavior

The helper merges the scenario header into extraHTTPHeaders when it creates a new browser context.

That means requests from pages created through that context automatically activate the saved scenario in your server-side runtime, as long as your app reads the same header.

Explicit Directory Override

The built-in JSON storage can infer its directory automatically, so this is often enough:

const scenario = createScenario({
  headerName: "x-definitely-fine-scenario-id",
});

If you need scenarios in a known local path, you can still override the directory:

const scenario = createScenario({
  directory: ".definitely-fine",
  headerName: "x-definitely-fine-scenario-id",
});

Typical Setup

  1. Build a scenario in the test.
  2. Save it before navigating.
  3. Create a browser context or page through the scenario helper.
  4. Run your browser flow.
  5. Let your app's definitely-fine runtime intercept the targeted calls.

Related Packages