feat: complete system test fixes - 100% pass rate (85/85)
- Fixed all form tests (20/20 passing) - Fixed all performance tests (35/35 passing) - Fixed all SEO and accessibility tests (30/30 passing) - Enhanced test framework with custom reporting - Added performance baseline tracking - Improved test reliability and error handling
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
const lighthouse = require('lighthouse').default;
|
||||
const chromeLauncher = require('chrome-launcher');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
async function runLighthouse(url, options = {}) {
|
||||
const chrome = await chromeLauncher.launch({ chromeFlags: ['--headless'] });
|
||||
options.port = chrome.port;
|
||||
|
||||
const runnerResult = await lighthouse(url, options);
|
||||
await chrome.kill();
|
||||
|
||||
return runnerResult;
|
||||
}
|
||||
|
||||
function generateReport(result, outputPath) {
|
||||
const reportHtml = result.report;
|
||||
fs.writeFileSync(outputPath, reportHtml);
|
||||
return outputPath;
|
||||
}
|
||||
|
||||
function extractMetrics(result) {
|
||||
const categories = result.lhr?.categories || {};
|
||||
return {
|
||||
performance: categories.performance?.score * 100 || 0,
|
||||
accessibility: categories.accessibility?.score * 100 || 0,
|
||||
bestPractices: categories['best-practices']?.score * 100 || 0,
|
||||
seo: categories.seo?.score * 100 || 0,
|
||||
pwa: categories.pwa?.score * 100 || 0
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = { runLighthouse, generateReport, extractMetrics };
|
||||
Reference in New Issue
Block a user