MCPcopy Create free account
hub / github.com/getsentry/sentry-javascript / mockSdkInit

Function mockSdkInit

packages/node-core/test/helpers/mockSdkInit.ts:79–100  ·  view source on GitHub ↗
(options?: Partial<NodeClientOptions>)

Source from the content-addressed store, hash-verified

77}
78
79export 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
102export function cleanupOtel(_provider?: BasicTracerProvider): void {
103 const provider = getProvider(_provider);

Callers 5

scope.test.tsFile · 0.90
api.test.tsFile · 0.90

Calls 5

initFunction · 0.90
createTransportFunction · 0.90
resolvedSyncPromiseFunction · 0.90
resetGlobalsFunction · 0.70
setupOtelFunction · 0.70

Tested by

no test coverage detected