11import { afterEach , beforeAll , beforeEach , describe , expect , test } from 'bun:test' ;
22import type { Span } from '@sentry/core' ;
3- import { getDynamicSamplingContextFromSpan , setCurrentClient , spanIsSampled , spanToJSON } from '@sentry/core' ;
3+ import { getDynamicSamplingContextFromSpan , spanIsSampled , spanToJSON } from '@sentry/core' ;
44
5- import { BunClient } from '../../src/client' ;
5+ import { init } from '../../src' ;
6+ import type { NodeClient } from '../../src' ;
67import { instrumentBunServe } from '../../src/integrations/bunserver' ;
78import { getDefaultBunClientOptions } from '../helpers' ;
89
910describe ( 'Bun Serve Integration' , ( ) => {
10- let client : BunClient ;
11+ let client : NodeClient | undefined ;
1112 // Fun fact: Bun = 2 21 14 :)
1213 let port : number = 22114 ;
1314
@@ -17,9 +18,7 @@ describe('Bun Serve Integration', () => {
1718
1819 beforeEach ( ( ) => {
1920 const options = getDefaultBunClientOptions ( { tracesSampleRate : 1 } ) ;
20- client = new BunClient ( options ) ;
21- setCurrentClient ( client ) ;
22- client . init ( ) ;
21+ client = init ( options ) ;
2322 } ) ;
2423
2524 afterEach ( ( ) => {
@@ -31,7 +30,7 @@ describe('Bun Serve Integration', () => {
3130 test ( 'generates a transaction around a request' , async ( ) => {
3231 let generatedSpan : Span | undefined ;
3332
34- client . on ( 'spanEnd' , span => {
33+ client ? .on ( 'spanEnd' , span => {
3534 generatedSpan = span ;
3635 } ) ;
3736
@@ -66,7 +65,7 @@ describe('Bun Serve Integration', () => {
6665 test ( 'generates a post transaction' , async ( ) => {
6766 let generatedSpan : Span | undefined ;
6867
69- client . on ( 'spanEnd' , span => {
68+ client ? .on ( 'spanEnd' , span => {
7069 generatedSpan = span ;
7170 } ) ;
7271
@@ -103,7 +102,7 @@ describe('Bun Serve Integration', () => {
103102
104103 let generatedSpan : Span | undefined ;
105104
106- client . on ( 'spanEnd' , span => {
105+ client ? .on ( 'spanEnd' , span => {
107106 generatedSpan = span ;
108107 } ) ;
109108
@@ -139,7 +138,7 @@ describe('Bun Serve Integration', () => {
139138 test ( 'does not create transactions for OPTIONS or HEAD requests' , async ( ) => {
140139 let generatedSpan : Span | undefined ;
141140
142- client . on ( 'spanEnd' , span => {
141+ client ? .on ( 'spanEnd' , span => {
143142 generatedSpan = span ;
144143 } ) ;
145144
@@ -165,7 +164,7 @@ describe('Bun Serve Integration', () => {
165164
166165 test ( 'intruments the server again if it is reloaded' , async ( ) => {
167166 let serverWasInstrumented = false ;
168- client . on ( 'spanEnd' , ( ) => {
167+ client ? .on ( 'spanEnd' , ( ) => {
169168 serverWasInstrumented = true ;
170169 } ) ;
171170
0 commit comments