Skip to content

Commit d0e19bc

Browse files
cjr125Christopher Roberts
authored andcommitted
added unit test
1 parent c6ce470 commit d0e19bc

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

packages/rum-core/test/performance-monitoring/transaction-service.spec.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,35 @@ describe('TransactionService', function () {
619619

620620
transaction.end(pageLoadTime + 1000)
621621
})
622+
623+
it('should capture tags from dispatch context', done => {
624+
// todo: can't test hard navigation metrics since karma runs tests inside an iframe
625+
config.setConfig({
626+
transactionContextCallback: () => {
627+
let stack
628+
try {
629+
throw new Error('')
630+
}
631+
catch (error) {
632+
stack = error.stack || ''
633+
}
634+
stack = stack.split('\n').map(function (line) { return line.trim(); })
635+
return { stack };
636+
}
637+
})
638+
const transactionService = new TransactionService(logger, config)
639+
640+
const tr1 = transactionService.startTransaction(
641+
'transaction1',
642+
'transaction'
643+
)
644+
645+
tr1.onEnd = () => {
646+
expect(tr1.options.tags.stack).toBeTruthy()
647+
done()
648+
}
649+
tr1.end()
650+
})
622651
})
623652

624653
it('should truncate active spans after transaction ends', () => {

0 commit comments

Comments
 (0)