From 254c9eab798f154cd4db8e04609169246f042726 Mon Sep 17 00:00:00 2001 From: Abhijeet Prasad Date: Wed, 26 Jul 2023 10:44:21 -0400 Subject: [PATCH] test(tracing): Add test for transaction trimEnd --- packages/tracing/test/hub.test.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/packages/tracing/test/hub.test.ts b/packages/tracing/test/hub.test.ts index 044582fcf6e2..37a7693ad389 100644 --- a/packages/tracing/test/hub.test.ts +++ b/packages/tracing/test/hub.test.ts @@ -624,4 +624,27 @@ The transaction will not be sampled. Please use the otel instrumentation to star }); }); }); + + describe('trimming transaction', () => { + describe('it should trim a transaction to the span timestamp if trimEnd is true', () => { + const options = getDefaultBrowserClientOptions({ + tracesSampleRate: 1, + dsn: 'https://username@domain/123', + }); + const client = new BrowserClient(options); + const hub = new Hub(client); + + const captureEventSpy = jest.spyOn(hub, 'captureEvent'); + + makeMain(hub); + const transaction = hub.startTransaction({ name: 'dogpark', startTimestamp: 1000, trimEnd: true }); + + transaction.startChild({ op: 'test', startTimestamp: 1200, endTimestamp: 1500 }); + + transaction.finish(2000); + + expect(captureEventSpy).toHaveBeenCalledTimes(1); + expect(captureEventSpy.mock.calls[0][0].timestamp).toEqual(1500); + }); + }); });