PerformanceAssertions

Playwright\Performance\Test\PerformanceAssertions

Trait providing performance-related assertions for PHPUnit tests.

$ composer require playwright-php/performance

Methods

assertLcpBelowThreshold()

void

Assert that LCP (Largest Contentful Paint) is below the specified threshold in milliseconds.

function assertLcpBelowThreshold(CoreWebVitals $vitals, float $thresholdMs, string $message = ''): void

assertLcpIsGood()

void

Assert that LCP is "Good" according to Core Web Vitals thresholds (<2.5s).

function assertLcpIsGood(CoreWebVitals $vitals, string $message = ''): void

assertFcpBelowThreshold()

void

Assert that FCP (First Contentful Paint) is below the specified threshold in milliseconds.

function assertFcpBelowThreshold(CoreWebVitals $vitals, float $thresholdMs, string $message = ''): void

assertFcpIsGood()

void

Assert that FCP is "Good" according to Core Web Vitals thresholds (<1.8s).

function assertFcpIsGood(CoreWebVitals $vitals, string $message = ''): void

assertClsBelowThreshold()

void

Assert that CLS (Cumulative Layout Shift) is below the specified threshold.

function assertClsBelowThreshold(CoreWebVitals $vitals, float $threshold, string $message = ''): void

assertClsIsGood()

void

Assert that CLS is "Good" according to Core Web Vitals thresholds (<0.1).

function assertClsIsGood(CoreWebVitals $vitals, string $message = ''): void

assertInpBelowThreshold()

void

Assert that INP (Interaction to Next Paint) is below the specified threshold in milliseconds. Note: INP requires real user interaction and may be 0 in automated tests.

function assertInpBelowThreshold(CoreWebVitals $vitals, float $thresholdMs, string $message = ''): void

assertInpIsGood()

void

Assert that INP is "Good" according to Core Web Vitals thresholds (<200ms). Note: INP requires real user interaction and may be 0 in automated tests.

function assertInpIsGood(CoreWebVitals $vitals, string $message = ''): void

assertFidBelowThreshold()

void

Assert that FID (First Input Delay) is below the specified threshold in milliseconds. Note: FID requires real user interaction and may be 0 in automated tests.

function assertFidBelowThreshold(CoreWebVitals $vitals, float $thresholdMs, string $message = ''): void

assertFidIsGood()

void

Assert that FID is "Good" according to Core Web Vitals thresholds (<100ms). Note: FID requires real user interaction and may be 0 in automated tests.

function assertFidIsGood(CoreWebVitals $vitals, string $message = ''): void

assertTtfbBelowThreshold()

void

Assert that TTFB (Time to First Byte) is below the specified threshold in milliseconds.

function assertTtfbBelowThreshold(CoreWebVitals $vitals, float $thresholdMs, string $message = ''): void

assertTtfbIsGood()

void

Assert that TTFB is "Good" according to Core Web Vitals thresholds (<800ms).

function assertTtfbIsGood(CoreWebVitals $vitals, string $message = ''): void

assertTbtBelowThreshold()

void

Assert that TBT (Total Blocking Time) is below the specified threshold in milliseconds.

function assertTbtBelowThreshold(CoreWebVitals $vitals, float $thresholdMs, string $message = ''): void

assertTbtIsGood()

void

Assert that TBT is "Good" according to Core Web Vitals thresholds (<200ms).

function assertTbtIsGood(CoreWebVitals $vitals, string $message = ''): void

assertAllCoreWebVitalsAreGood()

void

Assert that all Core Web Vitals are "Good" according to recommended thresholds. Note: INP and FID may be 0 in automated tests and will be skipped if so.

function assertAllCoreWebVitalsAreGood(CoreWebVitals $vitals, string $message = ''): void

assertResourceCountBelowThreshold()

void

Assert that the total number of resources is below the specified threshold.

function assertResourceCountBelowThreshold(array $resources, int $threshold, string $message = ''): void

assertTotalResourceSizeBelowThreshold()

void

Assert that the total size of all resources is below the specified threshold in bytes.

function assertTotalResourceSizeBelowThreshold(array $resources, int $thresholdBytes, string $message = ''): void

assertResourceTypeSizeBelowThreshold()

void

Assert that a specific resource type's total size is below the specified threshold in bytes.

function assertResourceTypeSizeBelowThreshold(array $resources, string $type, int $thresholdBytes, string $message = ''): void

assertNoResourceExceedsDuration()

void

Assert that no single resource exceeds the specified duration threshold in milliseconds.

function assertNoResourceExceedsDuration(array $resources, float $thresholdMs, string $message = ''): void