Skip to content

Commit 606c389

Browse files
committed
Adjust test and add comment to browser impl
1 parent 926984e commit 606c389

File tree

2 files changed

+14
-33
lines changed

2 files changed

+14
-33
lines changed

packages/angular/test/sdk.test.ts

Lines changed: 10 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as SentryBrowser from '@sentry/browser';
22
import { vi } from 'vitest';
3-
import { getDefaultIntegrations, init } from '../src/index';
3+
import { getDefaultIntegrations, init } from '../src/sdk';
44

55
describe('init', () => {
66
it('sets the Angular version (if available) in the global scope', () => {
@@ -14,39 +14,16 @@ describe('init', () => {
1414
expect(setContextSpy).toHaveBeenCalledWith('angular', { version: 14 });
1515
});
1616

17-
describe('filtering out the `BrowserApiErrors` integration', () => {
18-
const browserInitSpy = vi.spyOn(SentryBrowser, 'init');
17+
it('does not include the BrowserApiErrors integration', () => {
18+
const browserDefaultIntegrationsWithoutBrowserApiErrors = SentryBrowser.getDefaultIntegrations()
19+
.filter(i => i.name !== 'BrowserApiErrors')
20+
.map(i => i.name)
21+
.sort();
1922

20-
beforeEach(() => {
21-
browserInitSpy.mockClear();
22-
});
23+
const angularDefaultIntegrations = getDefaultIntegrations()
24+
.map(i => i.name)
25+
.sort();
2326

24-
it('filters if `defaultIntegrations` is not set', () => {
25-
init({});
26-
27-
expect(browserInitSpy).toHaveBeenCalledTimes(1);
28-
29-
const options = browserInitSpy.mock.calls[0][0] || {};
30-
expect(options.defaultIntegrations).not.toContainEqual(expect.objectContaining({ name: 'BrowserApiErrors' }));
31-
});
32-
33-
it("doesn't filter if `defaultIntegrations` is set to `false`", () => {
34-
init({ defaultIntegrations: false });
35-
36-
expect(browserInitSpy).toHaveBeenCalledTimes(1);
37-
38-
const options = browserInitSpy.mock.calls[0][0] || {};
39-
expect(options.defaultIntegrations).toEqual(false);
40-
});
41-
42-
it("doesn't filter if `defaultIntegrations` is overwritten", () => {
43-
const defaultIntegrations = getDefaultIntegrations({});
44-
init({ defaultIntegrations });
45-
46-
expect(browserInitSpy).toHaveBeenCalledTimes(1);
47-
48-
const options = browserInitSpy.mock.calls[0][0] || {};
49-
expect(options.defaultIntegrations).toEqual(defaultIntegrations);
50-
});
27+
expect(angularDefaultIntegrations).toEqual(browserDefaultIntegrationsWithoutBrowserApiErrors);
5128
});
5229
});

packages/browser/src/sdk.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ import { makeFetchTransport } from './transports/fetch';
3232

3333
/** Get the default integrations for the browser SDK. */
3434
export function getDefaultIntegrations(_options: Options): Integration[] {
35+
/**
36+
* Note: Please make sure this stays in sync with Angular SDK, which re-exports
37+
* `getDefaultIntegrations` but with an adjusted set of integrations.
38+
*/
3539
return [
3640
inboundFiltersIntegration(),
3741
functionToStringIntegration(),

0 commit comments

Comments
 (0)