1
1
import { afterEach , beforeAll , beforeEach , describe , expect , test } from 'bun:test' ;
2
2
import type { Span } from '@sentry/core' ;
3
- import { getDynamicSamplingContextFromSpan , setCurrentClient , spanIsSampled , spanToJSON } from '@sentry/core' ;
3
+ import { getDynamicSamplingContextFromSpan , spanIsSampled , spanToJSON } from '@sentry/core' ;
4
4
5
- import { BunClient } from '../../src/client' ;
5
+ import { init } from '../../src' ;
6
+ import type { NodeClient } from '../../src' ;
6
7
import { instrumentBunServe } from '../../src/integrations/bunserver' ;
7
8
import { getDefaultBunClientOptions } from '../helpers' ;
8
9
9
10
describe ( 'Bun Serve Integration' , ( ) => {
10
- let client : BunClient ;
11
+ let client : NodeClient | undefined ;
11
12
// Fun fact: Bun = 2 21 14 :)
12
13
let port : number = 22114 ;
13
14
@@ -17,9 +18,7 @@ describe('Bun Serve Integration', () => {
17
18
18
19
beforeEach ( ( ) => {
19
20
const options = getDefaultBunClientOptions ( { tracesSampleRate : 1 } ) ;
20
- client = new BunClient ( options ) ;
21
- setCurrentClient ( client ) ;
22
- client . init ( ) ;
21
+ client = init ( options ) ;
23
22
} ) ;
24
23
25
24
afterEach ( ( ) => {
@@ -31,7 +30,7 @@ describe('Bun Serve Integration', () => {
31
30
test ( 'generates a transaction around a request' , async ( ) => {
32
31
let generatedSpan : Span | undefined ;
33
32
34
- client . on ( 'spanEnd' , span => {
33
+ client ? .on ( 'spanEnd' , span => {
35
34
generatedSpan = span ;
36
35
} ) ;
37
36
@@ -66,7 +65,7 @@ describe('Bun Serve Integration', () => {
66
65
test ( 'generates a post transaction' , async ( ) => {
67
66
let generatedSpan : Span | undefined ;
68
67
69
- client . on ( 'spanEnd' , span => {
68
+ client ? .on ( 'spanEnd' , span => {
70
69
generatedSpan = span ;
71
70
} ) ;
72
71
@@ -103,7 +102,7 @@ describe('Bun Serve Integration', () => {
103
102
104
103
let generatedSpan : Span | undefined ;
105
104
106
- client . on ( 'spanEnd' , span => {
105
+ client ? .on ( 'spanEnd' , span => {
107
106
generatedSpan = span ;
108
107
} ) ;
109
108
@@ -139,7 +138,7 @@ describe('Bun Serve Integration', () => {
139
138
test ( 'does not create transactions for OPTIONS or HEAD requests' , async ( ) => {
140
139
let generatedSpan : Span | undefined ;
141
140
142
- client . on ( 'spanEnd' , span => {
141
+ client ? .on ( 'spanEnd' , span => {
143
142
generatedSpan = span ;
144
143
} ) ;
145
144
@@ -165,7 +164,7 @@ describe('Bun Serve Integration', () => {
165
164
166
165
test ( 'intruments the server again if it is reloaded' , async ( ) => {
167
166
let serverWasInstrumented = false ;
168
- client . on ( 'spanEnd' , ( ) => {
167
+ client ? .on ( 'spanEnd' , ( ) => {
169
168
serverWasInstrumented = true ;
170
169
} ) ;
171
170
0 commit comments