-
-
Notifications
You must be signed in to change notification settings - Fork 338
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e027a90
commit bc60bc6
Showing
3 changed files
with
79 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { Carrier, getCurrentHub, getMainCarrier } from '@sentry/core'; | ||
import { Transaction } from '@sentry/tracing'; | ||
import { Hub } from '@sentry/types'; | ||
|
||
import { _addTracingExtensions, StartTransactionFunction } from '../src/js/measurements'; | ||
|
||
describe('Tracing extensions', () => { | ||
let hub: Hub; | ||
let carrier: Carrier; | ||
let startTransaction: StartTransactionFunction | undefined; | ||
|
||
beforeEach(() => { | ||
_addTracingExtensions(); | ||
hub = getCurrentHub(); | ||
carrier = getMainCarrier(); | ||
startTransaction = carrier.__SENTRY__?.extensions?.startTransaction as StartTransactionFunction | undefined; | ||
}); | ||
|
||
test('transaction has default op', async () => { | ||
const transaction: Transaction = startTransaction?.apply(hub, [{}]); | ||
|
||
expect(transaction).toEqual(expect.objectContaining({ op: 'default' })); | ||
}); | ||
|
||
test('transaction does not overwrite custom op', async () => { | ||
const transaction: Transaction = startTransaction?.apply(hub, [{ op: 'custom' }]); | ||
|
||
expect(transaction).toEqual(expect.objectContaining({ op: 'custom' })); | ||
}); | ||
|
||
test('transaction start span creates default op', async () => { | ||
const transaction: Transaction = startTransaction?.apply(hub, [{ op: 'custom' }]); | ||
const span = transaction?.startChild(); | ||
|
||
expect(span).toEqual(expect.objectContaining({ op: 'default' })); | ||
}); | ||
|
||
test('transaction start span keeps custom op', async () => { | ||
const transaction: Transaction = startTransaction?.apply(hub, [{ op: 'custom' }]); | ||
const span = transaction?.startChild({ op: 'custom' }); | ||
|
||
expect(span).toEqual(expect.objectContaining({ op: 'custom' })); | ||
}); | ||
|
||
test('transaction start span passes correct values to the child', async () => { | ||
const transaction: Transaction = startTransaction?.apply(hub, [{ op: 'custom' }]); | ||
const span = transaction?.startChild({ op: 'custom' }); | ||
|
||
expect(span).toEqual(expect.objectContaining({ | ||
transaction, | ||
parentSpanId: transaction.spanId, | ||
sampled: transaction.sampled, | ||
traceId: transaction.traceId, | ||
})); | ||
}); | ||
}); |