Skip to content

Commit 7294db1

Browse files
committed
feat(browser): test for heartbeatInterval
Signed-off-by: Outsider <[email protected]>
1 parent a7b0cfc commit 7294db1

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

packages/tracing/test/browser/browsertracing.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,23 @@ describe('BrowserTracing', () => {
307307
expect(mockFinish).toHaveBeenCalledTimes(1);
308308
});
309309
});
310+
311+
describe('heartbeatInterval', () => {
312+
it('can be a custom value', () => {
313+
const interval = 200;
314+
createBrowserTracing(true, { heartbeatInterval: interval, routingInstrumentation: customInstrumentRouting });
315+
const mockFinish = jest.fn();
316+
const transaction = getActiveTransaction(hub) as IdleTransaction;
317+
transaction.finish = mockFinish;
318+
319+
const span = transaction.startChild(); // activities = 1
320+
span.finish(); // activities = 0
321+
322+
expect(mockFinish).toHaveBeenCalledTimes(0);
323+
jest.advanceTimersByTime(interval * 3);
324+
expect(mockFinish).toHaveBeenCalledTimes(1);
325+
});
326+
});
310327
});
311328

312329
// Integration tests for the default routing instrumentation

0 commit comments

Comments
 (0)