Skip to content

Commit 803c641

Browse files
authored
tests: fix telemetry span timeout (#5473)
Problem: - "returns the correct call stack when the context switches" uses sleep under the hood which requires manual ticks when fake clocks are installed. When we added the fake clock it caused this test to fail Solution: - only install the fake clock for "records performance"
1 parent 043881c commit 803c641

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

packages/core/src/test/shared/telemetry/spans.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,17 @@ describe('TelemetrySpan', function () {
9696

9797
describe('TelemetryTracer', function () {
9898
let tracer: TelemetryTracer
99-
let clock: ReturnType<typeof installFakeClock>
99+
let clock: ReturnType<typeof installFakeClock> | undefined
100100
let sandbox: SinonSandbox
101101
const metricName = 'test_metric' as MetricName
102102

103103
beforeEach(function () {
104104
tracer = new TelemetryTracer()
105-
clock = installFakeClock()
106105
sandbox = sinon.createSandbox()
107106
})
108107

109108
afterEach(function () {
110-
clock.uninstall()
109+
clock?.uninstall()
111110
sandbox.restore()
112111
})
113112

@@ -269,11 +268,12 @@ describe('TelemetryTracer', function () {
269268
})
270269

271270
it('records performance', function () {
271+
clock = installFakeClock()
272272
const { expectedCpuUsage, expectedHeapTotal } = stubPerformance(sandbox)
273273
tracer.run(
274274
'function_call',
275275
() => {
276-
clock.tick(90)
276+
clock?.tick(90)
277277
},
278278
{
279279
trackPerformance: true,

0 commit comments

Comments
 (0)