mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
As per the migration plan shared last year, this migrates all browser-based tests in WordPress core to use Playwright. This includes end-to-end, performance, and visual regression tests. Props swissspidy, mamaduka, kevin940726, bartkalisz, desrosj, adamsilverstein. Fixes #59517. git-svn-id: https://develop.svn.wordpress.org/trunk@56926 602fd350-edb4-49c9-b593-d223f7449a82
39 lines
863 B
JavaScript
39 lines
863 B
JavaScript
/**
|
|
* External dependencies
|
|
*/
|
|
import { join, dirname, basename } from 'node:path';
|
|
import { writeFileSync } from 'node:fs';
|
|
|
|
/**
|
|
* Internal dependencies
|
|
*/
|
|
import { getResultsFilename } from '../utils';
|
|
|
|
/**
|
|
* @implements {import('@playwright/test/reporter').Reporter}
|
|
*/
|
|
class PerformanceReporter {
|
|
/**
|
|
*
|
|
* @param {import('@playwright/test/reporter').TestCase} test
|
|
* @param {import('@playwright/test/reporter').TestResult} result
|
|
*/
|
|
onTestEnd( test, result ) {
|
|
const performanceResults = result.attachments.find(
|
|
( attachment ) => attachment.name === 'results'
|
|
);
|
|
|
|
if ( performanceResults?.body ) {
|
|
writeFileSync(
|
|
join(
|
|
dirname( test.location.file ),
|
|
getResultsFilename( basename( test.location.file, '.js' ) )
|
|
),
|
|
performanceResults.body.toString( 'utf-8' )
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
export default PerformanceReporter;
|