Skip to content

Commit

Permalink
added unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
cjr125 authored and Christopher Roberts committed Dec 4, 2024
1 parent c6ce470 commit 313f130
Showing 1 changed file with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import { state } from '../../src/state'
import { isPerfTypeSupported } from '../../src/common/utils'
import Transaction from '../../src/performance-monitoring/transaction'
import { metrics } from '../../src/performance-monitoring/metrics/metrics'
import { options } from 'benchmark'

describe('TransactionService', function () {
var transactionService
Expand Down Expand Up @@ -135,7 +136,7 @@ describe('TransactionService', function () {
events: {
send: onStartSpy
},
get: () => {}
get: () => { }
})
const options = {
managed: true,
Expand Down Expand Up @@ -619,6 +620,35 @@ describe('TransactionService', function () {

transaction.end(pageLoadTime + 1000)
})

it('should capture tags from dispatch context', done => {
// todo: can't test hard navigation metrics since karma runs tests inside an iframe
config.setConfig({
transactionContextCallback: () => {
let stack
try {
throw new Error('')
}
catch (error) {
stack = error.stack || ''
}
stack = stack.split('\n').map(function (line) { return line.trim(); })
return { stack };
}
})
const transactionService = new TransactionService(logger, config)

const tr1 = transactionService.startTransaction(
'transaction1',
'transaction'
)

tr1.onEnd = () => {
expect(tr1.options.tags.stack).toBeTruthy()
done()
}
tr1.end()
})
})

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

0 comments on commit 313f130

Please sign in to comment.