OpenQAOpenQA
Test Types

Performance Tests

Measure load times, resource usage, and application responsiveness.

What Gets Measured

Load Time

Time to first contentful paint

Core Web Vitals

LCP, FID, CLS metrics

API Response

Backend response times

Example Performance Test

test_page_performance.spec.ts
1import { test, expect } from '@playwright/test';
2 
3test.describe('Page Performance', () => {
4 test('homepage should load within 3 seconds', async ({ page }) => {
5 const startTime = Date.now();
6 
7 await page.goto('/');
8 await page.waitForLoadState('networkidle');
9 
10 const loadTime = Date.now() - startTime;
11 expect(loadTime).toBeLessThan(3000);
12 
13 // Check Core Web Vitals
14 const metrics = await page.evaluate(() => {
15 return new Promise((resolve) => {
16 new PerformanceObserver((list) => {
17 const entries = list.getEntries();
18 resolve({
19 lcp: entries.find(e => e.entryType === 'largest-contentful-paint'),
20 fid: entries.find(e => e.entryType === 'first-input'),
21 });
22 }).observe({ entryTypes: ['largest-contentful-paint', 'first-input'] });
23 });
24 });
25 
26 console.log('Performance metrics:', metrics);
27 });
28 
29 test('API responses should be under 500ms', async ({ page }) => {
30 const apiTimes: number[] = [];
31 
32 page.on('response', (response) => {
33 if (response.url().includes('/api/')) {
34 const timing = response.timing();
35 apiTimes.push(timing.responseEnd - timing.requestStart);
36 }
37 });
38 
39 await page.goto('/dashboard');
40 await page.waitForLoadState('networkidle');
41 
42 for (const time of apiTimes) {
43 expect(time).toBeLessThan(500);
44 }
45 });
46});

Generate Performance Tests

bash
1curl -X POST http://localhost:3000/api/brain/generate-test \
2 -H "Content-Type: application/json" \
3 -d '{
4 "type": "performance",
5 "target": "Homepage and dashboard load times"
6 }'

Next Steps