Skip to content

Commit

Permalink
add client test
Browse files Browse the repository at this point in the history
  • Loading branch information
lobsterkatie committed Oct 27, 2021
1 parent 28326da commit e32171b
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/nextjs/test/index.client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getCurrentHub } from '@sentry/hub';
import * as SentryReact from '@sentry/react';
import { Integrations as TracingIntegrations } from '@sentry/tracing';
import { Integration } from '@sentry/types';
import { getGlobalObject } from '@sentry/utils';
import { getGlobalObject, logger, SentryError } from '@sentry/utils';

import { init, Integrations, nextRouterInstrumentation } from '../src/index.client';
import { NextjsOptions } from '../src/utils/nextjsOptions';
Expand All @@ -12,6 +12,7 @@ const { BrowserTracing } = TracingIntegrations;
const global = getGlobalObject();

const reactInit = jest.spyOn(SentryReact, 'init');
const logError = jest.spyOn(logger, 'error');

describe('Client init()', () => {
afterEach(() => {
Expand Down Expand Up @@ -50,6 +51,18 @@ describe('Client init()', () => {
expect(currentScope._tags).toEqual({ runtime: 'browser' });
});

it('adds 404 transaction filter', () => {
init({
dsn: 'https://dogsarebadatkeepingsecrets@squirrelchasers.ingest.sentry.io/12312012',
tracesSampleRate: 1.0,
});

const transaction = getCurrentHub().startTransaction({ name: '/404' });
transaction.finish();

expect(logError).toHaveBeenCalledWith(new SentryError('An event processor returned null, will not send event.'));
});

describe('integrations', () => {
it('does not add BrowserTracing integration by default if tracesSampleRate is not set', () => {
init({});
Expand Down

0 comments on commit e32171b

Please sign in to comment.