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

ftmocks-utils

v1.5.3

Published

Util functions for FtMocks

Readme

ftmocks-utils

Util functions for FtMocks

Usage: initiatePlaywrightRoutes

initiatePlaywrightRoutes sets up Playwright network route mocks for your tests.

Example Test

import { test, expect } from "@playwright/test";
import { initiatePlaywrightRoutes } from "ftmocks-utils";

test("Sample test case", async ({ page }) => {
  // Initiate Playwright routes with custom directories and patterns
  await initiatePlaywrightRoutes(
    page,
    {
      MOCK_DIR: "../ftmocks",
      FALLBACK_DIR: "../public",
    },
    "Sample test case",
    "**/*" // Pattern(s) to intercept; you can use a string or array of patterns
  );

  await page.goto("https://example-test.com/");

  // Now your requests will be mocked as per your ftmocks setup
  // Add your test steps and assertions here
});

Parameters:

  • page: Playwright page object.
  • options: Object with configuration. At minimum, provide MOCK_DIR (required). FALLBACK_DIR is optional.
  • testName: (string) Name of this test, so ftmocks can find the right mock data.
  • patterns: (string or array) Glob patterns for requests to intercept.

Make sure your MOCK_DIR points to the directory where your FtMocks records are saved.

See more API documentation at ftmocks.com or in the main FtMocks repository.

Usage: recordPlaywrightRoutes

recordPlaywrightRoutes allows you to record network requests and responses from a Playwright test session and save them as FtMocks mocks. This is useful for setting up new mocks or updating existing ones with actual traffic.

Example Usage

import { test } from "@playwright/test";
import { recordPlaywrightRoutes } from "ftmocks-utils";

test("Record API interactions", async ({ page }) => {
  await recordPlaywrightRoutes(
    page,
    {
      MOCK_DIR: "../ftmocks",
      FALLBACK_DIR: "../public",
    },
    {
      testName: "Recorded test",
      mockPath: "**/*", // Intercept all requests by default
      pattern: "^/api/.*", // Only record requests matching this regex pattern (e.g., API endpoints)
      avoidDuplicatesInTheTest: true, // Skip duplicates within a single test recording
      avoidDuplicatesWithDefaultMocks: true, // Skip duplicates with default mocks
    }
  );

  await page.goto("https://your-app-under-test.com/");
  // Interact with your page as needed; API requests will be recorded
});

Parameters:

  • page: Playwright page object.
  • ftmocksConifg: Object, must contain at minimum MOCK_DIR. FALLBACK_DIR is optional.
  • config: Object containing recording options:
    • testName: (string) Name of the test, used for saving the mock data.
    • mockPath: (string|array) Glob pattern(s) for requests to intercept.
    • pattern: (string) Regex string; only requests matching this will be recorded.
    • avoidDuplicatesInTheTest: (boolean) Skip duplicate entries during this run.
    • avoidDuplicatesWithDefaultMocks: (boolean) Skip recording if identical default mocks are present.

After running the test, FtMocks-compatible mock files will be saved to the specified folder for easy reuse.

See more API documentation and advanced usage at ftmocks.com.