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 🙏

© 2024 – Pkg Stats / Ryan Hefner

polly-adapter-playwright

v2.4.0

Published

Polly.JS adapter for Playwright

Downloads

5,866

Readme

polly-adapter-playwright

npm license

Polly.JS adapter for Playwright. This adapter will attach to a given browser context or page from Playwright for recording and replaying requests.

Installation

npm:

npm install --save-dev polly-adapter-playwright

yarn:

yarn add --dev polly-adapter-playwright

Usage

This adapter works across all browsers supported by Playwright. Simply create a new browser context or page and pass it as an option to this adapter when creating a new Polly instance.

Examples

With a new page:

import { Polly } from '@pollyjs/core';
import { PlaywrightAdapter } from 'polly-adapter-playwright';
import { chromium } from 'playwright';

const browser = await chromium.launch();
const page = await browser.newPage();

// register the playwright adapter so it's accessible by all future polly instances
Polly.register(PlaywrightAdapter);

const polly = new Polly('<Recording Name>', {
  adapters: ['playwright'],
  adapterOptions: {
    playwright: {
      context: page
    }
  }
});

// perform page interactions
...

// cleanup
await polly.stop();
await page.close();

With a new browser context:

import { Polly } from '@pollyjs/core';
import { PlaywrightAdapter } from 'polly-adapter-playwright';
import { chromium } from 'playwright';

const browser = await chromium.launch();
const context = await browser.newContext();

// register the playwright adapter so it's accessible by all future polly instances
Polly.register(PlaywrightAdapter);

const polly = new Polly('<Recording Name>', {
  adapters: ['playwright'],
  adapterOptions: {
    playwright: {
      context
    }
  }
});

const page = await context.newPage();

// perform page interactions
...

// cleanup
await polly.stop();
await page.close();
await context.close();

Options

| Name | Description | | :--------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | context | The browser context or page where requests will be intercepted. | | handleFailingRequest | Controls how failing requests from Polly will be handled by Playwright. By default this calls route.abort(). | | modifyResponse | Fires before a response is fulfilled for any intercepted request. By default it will modify all responses to allow cross-origin resource sharing by setting the access-control-allow-origin header to *. | | routesToIntercept | Configures which routes should be intercepted. By default this is set to **\/* which means all routes. | | shouldHandleRequest | Specifies criteria that should be matched for a request to be intercepted. By default it will only match requests made by fetch or XMLHttpRequest calls. |