{"library":"playwright-performance","title":"Playwright Performance Testing Plugin","description":"playwright-performance is a plugin for Playwright that enables detailed performance analysis of end-to-end test flows, including UI, API, or hybrid scenarios. It measures the 'apparent response time' of key user procedures within your application, helping identify bottlenecks and areas for optimization. The current stable version is 2.0.6, with recent updates introducing HTML chart generation. The library maintains an active release cadence, with a major breaking change in version 2.x.x simplifying its integration model. Its key differentiator is the seamless integration into Playwright's `test.extend` fixture system, allowing developers to easily add performance sampling to existing tests without significant refactoring, and providing configurable output options for results.","language":"javascript","status":"active","last_verified":"Tue Apr 21","install":{"commands":["npm install playwright-performance"],"cli":null},"imports":["import extendPlaywrightPerformance from 'playwright-performance';","import type { PlaywrightPerformance } from 'playwright-performance';","import type { PerformanceOptions } from 'playwright-performance';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { test as base, expect } from '@playwright/test';\nimport extendPlaywrightPerformance, { PerformanceOptions, PlaywrightPerformance } from 'playwright-performance';\n\n// Extend the Playwright test object with performance fixtures\nconst test = base.extend<PlaywrightPerformance, PerformanceOptions>(extendPlaywrightPerformance());\n\ntest.describe('Website Startup Performance', () => {\n  test('should load GitHub and SourceForge within acceptable limits', async ({ page, performance }) => {\n    // Sample startup time for GitHub\n    performance.sampleStart('GH-startup');\n    await page.goto('https://github.com/', { waitUntil: 'domcontentloaded' });\n    performance.sampleEnd('GH-startup');\n\n    // Sample startup time for SourceForge\n    performance.sampleStart('SF-startup');\n    await page.goto('https://sourceforge.net/', { waitUntil: 'domcontentloaded' });\n    performance.sampleEnd('SF-startup');\n\n    // You can also get individual sample times within the test\n    const githubStartupTime = performance.getSampleTime('GH-startup');\n    const sourceForgeStartupTime = performance.getSampleTime('SF-startup');\n\n    // Assertions for performance metrics\n    expect(githubStartupTime).toBeLessThanOrEqual(5000); // Expect GitHub to load in under 5 seconds\n    expect(sourceForgeStartupTime).toBeLessThanOrEqual(8000); // Expect SourceForge to load in under 8 seconds\n\n    console.log(`GitHub Startup Time: ${githubStartupTime}ms`);\n    console.log(`SourceForge Startup Time: ${sourceForgeStartupTime}ms`);\n  });\n});","lang":"typescript","description":"Demonstrates how to extend Playwright's `test` object with performance fixtures, record startup times for multiple URLs, and assert on individual sample durations within an extended test.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}