Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions packages/bun/test/integrations/bunserver.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { beforeAll, beforeEach, describe, expect, test } from 'bun:test';
import { Hub, getDynamicSamplingContextFromSpan, makeMain, spanIsSampled, spanToJSON } from '@sentry/core';
import { getDynamicSamplingContextFromSpan, setCurrentClient, spanIsSampled, spanToJSON } from '@sentry/core';

import { BunClient } from '../../src/client';
import { instrumentBunServe } from '../../src/integrations/bunserver';
Expand All @@ -9,7 +9,6 @@ import { getDefaultBunClientOptions } from '../helpers';
const DEFAULT_PORT = 22114;

describe('Bun Serve Integration', () => {
let hub: Hub;
let client: BunClient;

beforeAll(() => {
Expand All @@ -19,10 +18,8 @@ describe('Bun Serve Integration', () => {
beforeEach(() => {
const options = getDefaultBunClientOptions({ tracesSampleRate: 1, debug: true });
client = new BunClient(options);
// eslint-disable-next-line deprecation/deprecation
hub = new Hub(client);
// eslint-disable-next-line deprecation/deprecation
makeMain(hub);
setCurrentClient(client);
client.init();
});

test('generates a transaction around a request', async () => {
Expand Down
25 changes: 8 additions & 17 deletions packages/core/test/lib/integration.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import type { Integration, Options } from '@sentry/types';
import { logger } from '@sentry/utils';
import { getCurrentScope } from '../../src/currentScopes';

import { Hub, makeMain } from '../../src/hub';
import {
addIntegration,
convertIntegrationFnToClass,
getIntegrationsToSetup,
installedIntegrations,
setupIntegration,
} from '../../src/integration';
import { setCurrentClient } from '../../src/sdk';
import { TestClient, getDefaultTestClientOptions } from '../mocks/client';

function getTestClient(): TestClient {
Expand Down Expand Up @@ -617,10 +618,7 @@ describe('addIntegration', () => {
}

const client = getTestClient();
// eslint-disable-next-line deprecation/deprecation
const hub = new Hub(client);
// eslint-disable-next-line deprecation/deprecation
makeMain(hub);
setCurrentClient(client);

const integration = new CustomIntegration();
addIntegration(integration);
Expand All @@ -636,10 +634,7 @@ describe('addIntegration', () => {
setupOnce = jest.fn();
}

// eslint-disable-next-line deprecation/deprecation
const hub = new Hub();
// eslint-disable-next-line deprecation/deprecation
makeMain(hub);
getCurrentScope().setClient(undefined);

const integration = new CustomIntegration();
addIntegration(integration);
Expand All @@ -662,10 +657,8 @@ describe('addIntegration', () => {
}

const client = getTestClient();
// eslint-disable-next-line deprecation/deprecation
const hub = new Hub(client);
// eslint-disable-next-line deprecation/deprecation
makeMain(hub);
setCurrentClient(client);
client.init();

const integration = new CustomIntegration();
addIntegration(integration);
Expand All @@ -686,10 +679,8 @@ describe('addIntegration', () => {
}

const client = getTestClient();
// eslint-disable-next-line deprecation/deprecation
const hub = new Hub(client);
// eslint-disable-next-line deprecation/deprecation
makeMain(hub);
setCurrentClient(client);
client.init();

const integration1 = new CustomIntegration();
const integration2 = new CustomIntegration();
Expand Down
9 changes: 3 additions & 6 deletions packages/core/test/lib/scope.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import type { Attachment, Breadcrumb, Client, Event } from '@sentry/types';
import {
Hub,
addTracingExtensions,
applyScopeDataToEvent,
getActiveSpan,
getCurrentScope,
getGlobalScope,
getIsolationScope,
makeMain,
setCurrentClient,
setGlobalScope,
spanToJSON,
startInactiveSpan,
Expand Down Expand Up @@ -555,10 +554,8 @@ describe('withActiveSpan()', () => {
beforeEach(() => {
const options = getDefaultTestClientOptions({ enableTracing: true });
const client = new TestClient(options);
const scope = new Scope();
// eslint-disable-next-line deprecation/deprecation
const hub = new Hub(client, scope);
makeMain(hub); // eslint-disable-line deprecation/deprecation
setCurrentClient(client);
client.init();
});

it('should set the active span within the callback', () => {
Expand Down
10 changes: 2 additions & 8 deletions packages/core/test/lib/sdk.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Hub, captureCheckIn, makeMain, setCurrentClient } from '@sentry/core';
import { captureCheckIn, getCurrentScope, setCurrentClient } from '@sentry/core';
import type { Client, Integration, IntegrationFnResult } from '@sentry/types';

import { installedIntegrations } from '../../src/integration';
Expand Down Expand Up @@ -86,13 +86,6 @@ describe('SDK', () => {
});

describe('captureCheckIn', () => {
afterEach(function () {
// eslint-disable-next-line deprecation/deprecation
const hub = new Hub();
// eslint-disable-next-line deprecation/deprecation
makeMain(hub);
});

it('returns an id when client is defined', () => {
const client = {
captureCheckIn: () => 'some-id-wasd-1234',
Expand All @@ -103,6 +96,7 @@ describe('captureCheckIn', () => {
});

it('returns an id when client is undefined', () => {
getCurrentScope().setClient(undefined);
expect(captureCheckIn({ monitorSlug: 'gogogo', status: 'in_progress' })).toStrictEqual(expect.any(String));
});
});
13 changes: 7 additions & 6 deletions packages/core/test/lib/tracing/dynamicSamplingContext.test.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import type { TransactionSource } from '@sentry/types';
import { Hub, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, makeMain } from '../../../src';
import {
SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE,
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
setCurrentClient,
} from '../../../src';
import { Transaction, getDynamicSamplingContextFromSpan, startInactiveSpan } from '../../../src/tracing';
import { addTracingExtensions } from '../../../src/tracing';
import { TestClient, getDefaultTestClientOptions } from '../../mocks/client';

describe('getDynamicSamplingContextFromSpan', () => {
let hub: Hub;
beforeEach(() => {
const options = getDefaultTestClientOptions({ tracesSampleRate: 1.0, release: '1.0.1' });
const client = new TestClient(options);
// eslint-disable-next-line deprecation/deprecation
hub = new Hub(client);
// eslint-disable-next-line deprecation/deprecation
makeMain(hub);
setCurrentClient(client);
client.init();
addTracingExtensions();
});

Expand Down
9 changes: 4 additions & 5 deletions packages/core/test/lib/tracing/errors.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BrowserClient } from '@sentry/browser';
import { Hub, addTracingExtensions, makeMain, spanToJSON, startInactiveSpan, startSpan } from '@sentry/core';
import { addTracingExtensions, setCurrentClient, spanToJSON, startInactiveSpan, startSpan } from '@sentry/core';
import type { HandlerDataError, HandlerDataUnhandledRejection } from '@sentry/types';

import { getDefaultBrowserClientOptions } from '../../../../tracing/test/testutils';
Expand Down Expand Up @@ -34,10 +34,9 @@ describe('registerErrorHandlers()', () => {
mockAddGlobalErrorInstrumentationHandler.mockClear();
mockAddGlobalUnhandledRejectionInstrumentationHandler.mockClear();
const options = getDefaultBrowserClientOptions({ enableTracing: true });
// eslint-disable-next-line deprecation/deprecation
const hub = new Hub(new BrowserClient(options));
// eslint-disable-next-line deprecation/deprecation
makeMain(hub);
const client = new BrowserClient(options);
setCurrentClient(client);
client.init();
});

it('registers error instrumentation', () => {
Expand Down
Loading