forked from WordPress/wordpress-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.test.js
More file actions
46 lines (38 loc) · 1.1 KB
/
admin.test.js
File metadata and controls
46 lines (38 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/**
* WordPress dependencies
*/
import { test } from '@wordpress/e2e-test-utils-playwright';
/**
* Internal dependencies
*/
import { camelCaseDashes } from '../utils';
const results = {
timeToFirstByte: [],
};
test.describe( 'Admin', () => {
test.beforeAll( async ( { requestUtils } ) => {
await requestUtils.activateTheme( 'twentytwentyone' );
} );
test.afterAll( async ( {}, testInfo ) => {
await testInfo.attach( 'results', {
body: JSON.stringify( results, null, 2 ),
contentType: 'application/json',
} );
} );
const iterations = Number( process.env.TEST_RUNS );
for ( let i = 1; i <= iterations; i++ ) {
test( `Measure load time metrics (${ i } of ${ iterations })`, async ( {
admin,
metrics,
} ) => {
await admin.visitAdminPage( '/' );
const serverTiming = await metrics.getServerTiming();
for ( const [ key, value ] of Object.entries( serverTiming ) ) {
results[ camelCaseDashes( key ) ] ??= [];
results[ camelCaseDashes( key ) ].push( value );
}
const ttfb = await metrics.getTimeToFirstByte();
results.timeToFirstByte.push( ttfb );
} );
}
} );