Change PerformanceReporter tests to not check exact values for timestamps (#27459)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
273c7df69b
Коммит
c39a4b2a7c
@@ -31,17 +31,15 @@ describe('PerformanceReporter', () => {
|
|||||||
|
|
||||||
expect(sendBeacon).not.toHaveBeenCalled();
|
expect(sendBeacon).not.toHaveBeenCalled();
|
||||||
|
|
||||||
const testMarkA = performance.mark('testMarkA');
|
performance.mark('testMarkA');
|
||||||
const testMarkB = performance.mark('testMarkB');
|
performance.mark('testMarkB');
|
||||||
|
|
||||||
const timeA = Date.now();
|
|
||||||
measureAndReport('testMeasureA', 'testMarkA', 'testMarkB');
|
measureAndReport('testMeasureA', 'testMarkA', 'testMarkB');
|
||||||
|
|
||||||
await waitForObservations();
|
await waitForObservations();
|
||||||
|
|
||||||
const testMarkC = performance.mark('testMarkC');
|
performance.mark('testMarkC');
|
||||||
|
|
||||||
const timeBC = Date.now();
|
|
||||||
measureAndReport('testMeasureB', 'testMarkA', 'testMarkC');
|
measureAndReport('testMeasureB', 'testMarkA', 'testMarkC');
|
||||||
measureAndReport('testMeasureC', 'testMarkB', 'testMarkC');
|
measureAndReport('testMeasureC', 'testMarkB', 'testMarkC');
|
||||||
|
|
||||||
@@ -58,24 +56,20 @@ describe('PerformanceReporter', () => {
|
|||||||
histograms: [
|
histograms: [
|
||||||
{
|
{
|
||||||
metric: 'testMeasureA',
|
metric: 'testMeasureA',
|
||||||
value: testMarkB.startTime - testMarkA.startTime,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
metric: 'testMeasureB',
|
metric: 'testMeasureB',
|
||||||
value: testMarkC.startTime - testMarkA.startTime,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
metric: 'testMeasureC',
|
metric: 'testMeasureC',
|
||||||
value: testMarkC.startTime - testMarkB.startTime,
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
expect(report.start).toEqual(report.histograms[0].timestamp);
|
expect(report.start).toEqual(Math.min(report.histograms[0].timestamp, report.histograms[1].timestamp, report.histograms[2].timestamp));
|
||||||
expect(report.end).toEqual(report.histograms[2].timestamp);
|
expect(report.end).toEqual(Math.max(report.histograms[0].timestamp, report.histograms[1].timestamp, report.histograms[2].timestamp));
|
||||||
expect(report.histograms[0].timestamp).toBeGreaterThanOrEqual(timeA);
|
expect(report.histograms[0].timestamp).toBeDefined();
|
||||||
expect(report.histograms[0].timestamp).toBeLessThanOrEqual(timeBC);
|
expect(report.histograms[1].timestamp).toBeDefined();
|
||||||
expect(report.histograms[1].timestamp).toBeGreaterThanOrEqual(timeBC);
|
expect(report.histograms[2].timestamp).toBeDefined();
|
||||||
expect(report.histograms[2].timestamp).toBeGreaterThanOrEqual(timeBC);
|
|
||||||
|
|
||||||
reporter.disconnect();
|
reporter.disconnect();
|
||||||
});
|
});
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user