Warning
This is in a prototype / proof-of-concept stage 🐱
A utility to monitor asset size in dynamic applications using playwright
npm install @nicktomlin/playwright-assets
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" })
})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)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