Skip to content

Commit 6ffc8a3

Browse files
authored
test(tracing): Add test for transaction trimEnd (#8651)
A validation test for transaction trim end since I noticed this wasn't being tested. Trying to sanity check why trimming is not working for some timestamps.
1 parent 500fc66 commit 6ffc8a3

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

packages/tracing/test/hub.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,4 +624,27 @@ The transaction will not be sampled. Please use the otel instrumentation to star
624624
});
625625
});
626626
});
627+
628+
describe('trimming transaction', () => {
629+
describe('it should trim a transaction to the span timestamp if trimEnd is true', () => {
630+
const options = getDefaultBrowserClientOptions({
631+
tracesSampleRate: 1,
632+
dsn: 'https://username@domain/123',
633+
});
634+
const client = new BrowserClient(options);
635+
const hub = new Hub(client);
636+
637+
const captureEventSpy = jest.spyOn(hub, 'captureEvent');
638+
639+
makeMain(hub);
640+
const transaction = hub.startTransaction({ name: 'dogpark', startTimestamp: 1000, trimEnd: true });
641+
642+
transaction.startChild({ op: 'test', startTimestamp: 1200, endTimestamp: 1500 });
643+
644+
transaction.finish(2000);
645+
646+
expect(captureEventSpy).toHaveBeenCalledTimes(1);
647+
expect(captureEventSpy.mock.calls[0][0].timestamp).toEqual(1500);
648+
});
649+
});
627650
});

0 commit comments

Comments
 (0)