-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Expand file tree
/
Copy pathtiming-summary-test.js
More file actions
85 lines (80 loc) · 3.63 KB
/
Copy pathtiming-summary-test.js
File metadata and controls
85 lines (80 loc) · 3.63 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/**
* @license
* Copyright 2019 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import {TimingSummary} from '../../../computed/metrics/timing-summary.js';
import {getURLArtifactFromDevtoolsLog, readJson} from '../../test-utils.js';
const trace = readJson('../../fixtures/traces/frame-metrics-m90.json', import.meta);
const devtoolsLog = readJson('../../fixtures/traces/frame-metrics-m90.devtools.log.json', import.meta);
describe('Timing summary', () => {
it('contains the correct data', async () => {
const gatherContext = {gatherMode: 'navigation'};
const context = {computedCache: new Map()};
const URL = getURLArtifactFromDevtoolsLog(devtoolsLog);
const artifacts =
// eslint-disable-next-line max-len
{URL, settings: {throttlingMethod: 'devtools'}, trace, devtoolsLog, SourceMaps: [], gatherContext};
const result = await TimingSummary.request(artifacts, context);
expect(result.metrics).toMatchInlineSnapshot(`
Object {
"cumulativeLayoutShift": 0.026463014612806653,
"cumulativeLayoutShiftMainFrame": 0.0011656245471340055,
"firstContentfulPaint": 5668.275,
"firstContentfulPaintAllFrames": 697.751,
"firstContentfulPaintAllFramesTs": 10327885660,
"firstContentfulPaintTs": 10332856184,
"interactive": 8654.264,
"interactiveTs": 10335842173,
"largestContentfulPaint": 5668.275,
"largestContentfulPaintAllFrames": 697.751,
"largestContentfulPaintAllFramesTs": 10327885660,
"largestContentfulPaintTs": 10332856184,
"lcpLoadDelay": undefined,
"lcpLoadDuration": undefined,
"lcpRenderDelay": 5097.946,
"maxPotentialFID": 51.056,
"observedCumulativeLayoutShift": 0.026463014612806653,
"observedCumulativeLayoutShiftMainFrame": 0.0011656245471340055,
"observedDomContentLoaded": 604.135,
"observedDomContentLoadedTs": 10327792044,
"observedFirstContentfulPaint": 5668.275,
"observedFirstContentfulPaintAllFrames": 697.751,
"observedFirstContentfulPaintAllFramesTs": 10327885660,
"observedFirstContentfulPaintTs": 10332856184,
"observedFirstPaint": 669.212,
"observedFirstPaintTs": 10327857121,
"observedFirstVisualChange": 673,
"observedFirstVisualChangeTs": 10327860909,
"observedLargestContentfulPaint": 5668.275,
"observedLargestContentfulPaintAllFrames": 697.751,
"observedLargestContentfulPaintAllFramesTs": 10327885660,
"observedLargestContentfulPaintTs": 10332856184,
"observedLastVisualChange": 5711,
"observedLastVisualChangeTs": 10332898909,
"observedLoad": 688.184,
"observedLoadTs": 10327876093,
"observedNavigationStart": 0,
"observedNavigationStartTs": 10327187909,
"observedSpeedIndex": 1334.5801200005412,
"observedSpeedIndexTs": 10328522489.12,
"observedTimeOrigin": 0,
"observedTimeOriginTs": 10327187909,
"observedTraceEnd": 14214.313,
"observedTraceEndTs": 10341402222,
"speedIndex": 1335,
"speedIndexTs": 10328522909,
"timeToFirstByte": 570.329,
"timeToFirstByteTs": 10327758238,
"totalBlockingTime": 2.7429999999994834,
}
`);
// Includes performance metrics
expect(result.metrics.firstContentfulPaint).toBeDefined();
// Includes timestamps from the processed trace
expect(result.metrics.observedFirstContentfulPaint).toBeDefined();
// Includs visual metrics from Speedline
expect(result.metrics.observedFirstVisualChange).toBeDefined();
expect(result.debugInfo).toEqual({lcpInvalidated: false});
});
});