A Playwright test utility for caching network requests on the filesystem to speed up E2E tests. Version 0.3.0 is the latest stable release, with a focus on simplicity and transparency (cached responses stored as clear JSON files, not HAR). It supports automatic caching, TTL-based refresh, runtime response modification, and flexible path splitting. Unlike manual mocking or HAR-based tools, it requires no setup beyond a fixture and works transparently with real API calls. Release cadence is irregular; maintained by vitalets. Ships TypeScript types.
npm install playwright-network-cacheNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates setting up a CacheRoute fixture with TTL and using GET to cache an API call.
Update Playwright to >=1.20 or use a compatible version of the library.
Use `baseDir` instead of `baseDirectory` in options.
Add a cleanup step in your test setup or CI, or set `ttlMinutes` to force refresh periodically.
For HEAD, OPTIONS, etc., use the generic `route` method.
Use the `splitByUrlParams` option to group similar URLs, or implement custom `matchRequest` logic.
Set `"type": "module"` in package.json, or use `import('playwright-network-cache').then(mod => ...)`Use `new CacheRoute(page, opts)` consistently.
Run `npm i -D playwright-network-cache` and verify package.json has it as devDependency.
Ensure each pattern is only cached once per test, or use `cacheRoute.ALL` with `matchRequest` to handle multiple patterns.
Use `import CacheRoute from 'playwright-network-cache'` and instantiate with `new`.