Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
s1gr1d committed Jul 23, 2024
1 parent d9f4d16 commit 2c4ff4d
Showing 1 changed file with 1 addition and 32 deletions.
33 changes: 1 addition & 32 deletions packages/nuxt/test/client/sdk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ describe('Nuxt Client SDK', () => {
['tracesSampleRate', { tracesSampleRate: 0 }],
['tracesSampler', { tracesSampler: () => 1.0 }],
['enableTracing', { enableTracing: true }],
['no tracing option set', {}] /* enable "tracing without performance" by default */,
])('adds a browserTracingIntegration if tracing is enabled via %s', (_, tracingOptions) => {
init({
dsn: 'https://[email protected]/1337',
Expand All @@ -49,38 +50,6 @@ describe('Nuxt Client SDK', () => {
const browserTracing = getClient<BrowserClient>()?.getIntegrationByName('BrowserTracing');
expect(browserTracing).toBeDefined();
});

it.each([
['enableTracing', { enableTracing: false }],
['no tracing option set', {}],
])("doesn't add a browserTracingIntegration integration if tracing is disabled via %s", (_, tracingOptions) => {
init({
dsn: 'https://[email protected]/1337',
...tracingOptions,
});

const browserTracing = getClient<BrowserClient>()?.getIntegrationByName('BrowserTracing');
expect(browserTracing).toBeUndefined();
});

it("doesn't add a browserTracingIntegration if `__SENTRY_TRACING__` is set to false", () => {
// This is the closest we can get to unit-testing the `__SENTRY_TRACING__` tree-shaking guard
// IRL, the code to add the integration would most likely be removed by the bundler.

// @ts-expect-error: Testing purposes
globalThis.__SENTRY_TRACING__ = false;

init({
dsn: 'https://[email protected]/1337',
tracesSampleRate: 0.3,
});

const browserTracing = getClient<BrowserClient>()?.getIntegrationByName('BrowserTracing');
expect(browserTracing).toBeUndefined();

// @ts-expect-error: Testing purposes
delete globalThis.__SENTRY_TRACING__;
});
});

it('returns client from init', () => {
Expand Down

0 comments on commit 2c4ff4d

Please sign in to comment.