@nicktomlin/playwright-assets
v1.0.1
Published
A utility to monitor asset size in dynamic applications
Readme
[!WARNING]
This is in a prototype / proof-of-concept stage 🐱
🤖 playwright-assets
A utility to monitor asset size in dynamic applications using playwright
Usage
Installation
npm install @nicktomlin/playwright-assetsWithin a test
import {assetExpect, collectStats} from "@nicktomlin/playwright-assets"
test("should have a small bundle", async ({page}) => {
const stats = await collectStats(
page,
async () => page.goto("https://www.google.com")
)
assetExpect(stats).toHaveAssetsLessThan('script', 180, { unit: "kb" })
})As a library
import {collectStats} from "@nicktomlin/playwright-assets"
import { chromium } from 'playwright';
const browser = await chromium.launch()
const page = await browser.newPage();
const stats = await collectStats(
page,
async () => page.goto("https://www.google.com")
)
console.log(stats)CLI
Currently, there's no plans for a cli given how complex this setup can be. If this would be of interest to you, please submit a PR with a design proposal
Prior art
- https://github.com/andersonba/puppeteer-assets
