Skip to content

Commit 15cc7e9

Browse files
author
Luca Forstner
committed
Add test
1 parent 4823b23 commit 15cc7e9

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

packages/browser-utils/test/browser/browserMetrics.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,29 @@ describe('_addMeasureSpans', () => {
9292
}),
9393
);
9494
});
95+
96+
it('drops measurement spans with negative duration', () => {
97+
const spans: Span[] = [];
98+
99+
getClient()?.on('spanEnd', span => {
100+
spans.push(span);
101+
});
102+
103+
const entry = {
104+
entryType: 'measure',
105+
name: 'measure-1',
106+
duration: 10,
107+
startTime: 12,
108+
} as PerformanceEntry;
109+
110+
const timeOrigin = 100;
111+
const startTime = 23;
112+
const duration = -50;
113+
114+
_addMeasureSpans(span, entry, startTime, duration, timeOrigin);
115+
116+
expect(spans).toHaveLength(0);
117+
});
95118
});
96119

97120
describe('_addResourceSpans', () => {

0 commit comments

Comments
 (0)