Skip to content

Commit 108a2ba

Browse files
author
Luca Forstner
committed
merge
2 parents 8915c83 + 3d098ff commit 108a2ba

File tree

11 files changed

+71
-67
lines changed

11 files changed

+71
-67
lines changed

packages/browser/test/unit/helper/browser-client-options.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { NoopTransport } from '@sentry/core';
2+
23
import { BrowserClientOptions } from '../../../src/client';
34

45
export function getDefaultBrowserClientOptions(options: Partial<BrowserClientOptions> = {}): BrowserClientOptions {

packages/browser/test/unit/sdk.test.ts

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
/* eslint-disable @typescript-eslint/unbound-method */
12
import { NoopTransport, Scope } from '@sentry/core';
2-
import { Client, Integration } from '@sentry/types';
3-
43
import { MockIntegration } from '@sentry/core/test/lib/sdk.test';
4+
import { Client, Integration } from '@sentry/types';
55

6-
import { init } from '../../src/sdk';
76
import { BrowserOptions } from '../../src';
7+
import { init } from '../../src/sdk';
88
// eslint-disable-next-line no-var
99
declare var global: any;
1010

@@ -62,8 +62,8 @@ describe('init', () => {
6262

6363
init(options);
6464

65-
expect((DEFAULT_INTEGRATIONS[0].setupOnce as jest.Mock).mock.calls.length).toBe(1);
66-
expect((DEFAULT_INTEGRATIONS[1].setupOnce as jest.Mock).mock.calls.length).toBe(1);
65+
expect(DEFAULT_INTEGRATIONS[0].setupOnce as jest.Mock).toHaveBeenCalledTimes(1);
66+
expect(DEFAULT_INTEGRATIONS[1].setupOnce as jest.Mock).toHaveBeenCalledTimes(1);
6767
});
6868

6969
test("doesn't install default integrations if told not to", () => {
@@ -74,20 +74,17 @@ describe('init', () => {
7474
const options = getDefaultBrowserOptions({ dsn: PUBLIC_DSN, defaultIntegrations: false });
7575
init(options);
7676

77-
expect((DEFAULT_INTEGRATIONS[0].setupOnce as jest.Mock).mock.calls.length).toBe(0);
78-
expect((DEFAULT_INTEGRATIONS[1].setupOnce as jest.Mock).mock.calls.length).toBe(0);
77+
expect(DEFAULT_INTEGRATIONS[0].setupOnce as jest.Mock).toHaveBeenCalledTimes(0);
78+
expect(DEFAULT_INTEGRATIONS[1].setupOnce as jest.Mock).toHaveBeenCalledTimes(0);
7979
});
8080

8181
it('installs merged default integrations, with overrides provided through options', () => {
82-
const DEFAULT_INTEGRATIONS: Integration[] = [
82+
const DEFAULT_INTEGRATIONS = [
8383
new MockIntegration('MockIntegration 1.1'),
8484
new MockIntegration('MockIntegration 1.2'),
8585
];
8686

87-
const integrations: Integration[] = [
88-
new MockIntegration('MockIntegration 1.1'),
89-
new MockIntegration('MockIntegration 1.3'),
90-
];
87+
const integrations = [new MockIntegration('MockIntegration 1.1'), new MockIntegration('MockIntegration 1.3')];
9188
const options = getDefaultBrowserOptions({
9289
dsn: PUBLIC_DSN,
9390
defaultIntegrations: DEFAULT_INTEGRATIONS,
@@ -103,7 +100,7 @@ describe('init', () => {
103100
});
104101

105102
it('installs integrations returned from a callback function', () => {
106-
const DEFAULT_INTEGRATIONS: Integration[] = [
103+
const DEFAULT_INTEGRATIONS = [
107104
new MockIntegration('MockIntegration 2.1'),
108105
new MockIntegration('MockIntegration 2.2'),
109106
];

packages/core/test/lib/base.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { dsnToString, logger, SentryError, SyncPromise } from '@sentry/utils';
44

55
import * as integrationModule from '../../src/integration';
66
import { NoopTransport } from '../../src/transports/noop';
7-
import { setupTestTransport, TestClient, getDefaultTestClientOptions } from '../mocks/client';
7+
import { getDefaultTestClientOptions, setupTestTransport, TestClient } from '../mocks/client';
88
import { TestIntegration } from '../mocks/integration';
99
import { FakeTransport } from '../mocks/transport';
1010

packages/core/test/lib/sdk.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Client, Integration } from '@sentry/types';
33

44
import { installedIntegrations } from '../../src/integration';
55
import { initAndBind } from '../../src/sdk';
6-
import { setupTestTransport, TestClient, getDefaultTestClientOptions } from '../mocks/client';
6+
import { getDefaultTestClientOptions, setupTestTransport, TestClient } from '../mocks/client';
77

88
// eslint-disable-next-line no-var
99
declare var global: any;

packages/tracing/test/browser/backgroundtab.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { BrowserClient } from '@sentry/browser';
22
import { setupBrowserTransport } from '@sentry/browser/src/transports';
3+
import { getDefaultBrowserClientOptions } from '@sentry/browser/test/unit/helper/browser-client-options';
34
import { Hub, makeMain } from '@sentry/hub';
45
import { JSDOM } from 'jsdom';
56

@@ -14,7 +15,7 @@ describe('registerBackgroundTabDetection', () => {
1415
// @ts-ignore need to override global document
1516
global.document = dom.window.document;
1617

17-
const options = { tracesSampleRate: 1 };
18+
const options = getDefaultBrowserClientOptions({ tracesSampleRate: 1 });
1819
hub = new Hub(new BrowserClient(options, setupBrowserTransport(options).transport));
1920
makeMain(hub);
2021

packages/tracing/test/browser/browsertracing.test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { BrowserClient } from '@sentry/browser';
22
import { setupBrowserTransport } from '@sentry/browser/src/transports';
3+
import { getDefaultBrowserClientOptions } from '@sentry/browser/test/unit/helper/browser-client-options';
34
import { Hub, makeMain } from '@sentry/hub';
45
import { getGlobalObject, InstrumentHandlerCallback, InstrumentHandlerType } from '@sentry/utils';
56
import { JSDOM } from 'jsdom';
@@ -52,7 +53,7 @@ describe('BrowserTracing', () => {
5253
let hub: Hub;
5354
beforeEach(() => {
5455
jest.useFakeTimers();
55-
const options = { tracesSampleRate: 1 };
56+
const options = getDefaultBrowserClientOptions({ tracesSampleRate: 1 });
5657
hub = new Hub(new BrowserClient(options, setupBrowserTransport(options).transport));
5758
makeMain(hub);
5859
document.head.innerHTML = '';
@@ -474,7 +475,7 @@ describe('BrowserTracing', () => {
474475
getGlobalObject<Window>().location = dogParkLocation as any;
475476

476477
const tracesSampler = jest.fn();
477-
const options = { tracesSampler };
478+
const options = getDefaultBrowserClientOptions({ tracesSampler });
478479
hub.bindClient(new BrowserClient(options, setupBrowserTransport(options).transport));
479480
// setting up the BrowserTracing integration automatically starts a pageload transaction
480481
createBrowserTracing(true);
@@ -491,7 +492,7 @@ describe('BrowserTracing', () => {
491492
getGlobalObject<Window>().location = dogParkLocation as any;
492493

493494
const tracesSampler = jest.fn();
494-
const options = { tracesSampler };
495+
const options = getDefaultBrowserClientOptions({ tracesSampler });
495496
hub.bindClient(new BrowserClient(options, setupBrowserTransport(options).transport));
496497
// setting up the BrowserTracing integration normally automatically starts a pageload transaction, but that's not
497498
// what we're testing here

packages/tracing/test/browser/request.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { BrowserClient } from '@sentry/browser';
22
import { setupBrowserTransport } from '@sentry/browser/src/transports';
3+
import { getDefaultBrowserClientOptions } from '@sentry/browser/test/unit/helper/browser-client-options';
34
import { Hub, makeMain } from '@sentry/hub';
45
import * as utils from '@sentry/utils';
56

@@ -73,7 +74,7 @@ describe('callbacks', () => {
7374
};
7475

7576
beforeAll(() => {
76-
const options = { tracesSampleRate: 1 };
77+
const options = getDefaultBrowserClientOptions({ tracesSampleRate: 1 });
7778
hub = new Hub(new BrowserClient(options, setupBrowserTransport(options).transport));
7879
makeMain(hub);
7980
});

packages/tracing/test/errors.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { BrowserClient } from '@sentry/browser';
22
import { setupBrowserTransport } from '@sentry/browser/src/transports';
3+
import { NoopTransport } from '@sentry/core/src/transports/noop';
34
import { Hub, makeMain } from '@sentry/hub';
45
import { InstrumentHandlerCallback, InstrumentHandlerType } from '@sentry/utils';
56

67
import { registerErrorInstrumentation } from '../src/errors';
78
import { _addTracingExtensions } from '../src/hubextensions';
8-
import { NoopTransport } from '@sentry/core/src/transports/noop';
99

1010
const mockAddInstrumentationHandler = jest.fn();
1111
let mockErrorCallback: InstrumentHandlerCallback = () => undefined;

0 commit comments

Comments
 (0)