(options?: Partial<NodeClientOptions>)
| 77 | } |
| 78 | |
| 79 | export function mockSdkInit(options?: Partial<NodeClientOptions>) { |
| 80 | resetGlobals(); |
| 81 | const client = init({ |
| 82 | dsn: PUBLIC_DSN, |
| 83 | defaultIntegrations: false, |
| 84 | // We are disabling client reports because we would be acquiring resources with every init call and that would leak |
| 85 | // memory every time we call init in the tests |
| 86 | sendClientReports: false, |
| 87 | // Use a mock transport to prevent network calls |
| 88 | transport: () => createTransport({ recordDroppedEvent: () => undefined }, _ => resolvedSyncPromise({})), |
| 89 | ...options, |
| 90 | }); |
| 91 | |
| 92 | // Always set up OpenTelemetry if we have a client |
| 93 | if (client) { |
| 94 | const provider = setupOtel(client); |
| 95 | // Important: Link the provider to the client so getProvider() can find it |
| 96 | client.traceProvider = provider; |
| 97 | } |
| 98 | |
| 99 | return client; |
| 100 | } |
| 101 | |
| 102 | export function cleanupOtel(_provider?: BasicTracerProvider): void { |
| 103 | const provider = getProvider(_provider); |
no test coverage detected