|
6 | 6 | import type { Mock } from 'vitest';
|
7 | 7 | import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
8 | 8 |
|
| 9 | +import * as SentryCore from '@sentry/core'; |
9 | 10 | import { Scope, createTransport } from '@sentry/core';
|
10 | 11 | import type { Client, Integration } from '@sentry/types';
|
11 | 12 | import { resolvedSyncPromise } from '@sentry/utils';
|
@@ -79,6 +80,18 @@ describe('init', () => {
|
79 | 80 | expect(DEFAULT_INTEGRATIONS[1]!.setupOnce as Mock).toHaveBeenCalledTimes(1);
|
80 | 81 | });
|
81 | 82 |
|
| 83 | + it('installs default integrations if `defaultIntegrations: undefined`', () => { |
| 84 | + // @ts-expect-error this is fine for testing |
| 85 | + const initAndBindSpy = vi.spyOn(SentryCore, 'initAndBind').mockImplementationOnce(() => {}); |
| 86 | + const options = getDefaultBrowserOptions({ dsn: PUBLIC_DSN, defaultIntegrations: undefined }); |
| 87 | + init(options); |
| 88 | + |
| 89 | + expect(initAndBindSpy).toHaveBeenCalledTimes(1); |
| 90 | + |
| 91 | + const optionsPassed = initAndBindSpy.mock.calls[0]?.[1]; |
| 92 | + expect(optionsPassed?.integrations?.length).toBeGreaterThan(0); |
| 93 | + }); |
| 94 | + |
82 | 95 | test("doesn't install default integrations if told not to", () => {
|
83 | 96 | const DEFAULT_INTEGRATIONS: Integration[] = [
|
84 | 97 | new MockIntegration('MockIntegration 0.3'),
|
@@ -150,6 +163,7 @@ describe('init', () => {
|
150 | 163 | Object.defineProperty(WINDOW, 'browser', { value: undefined, writable: true });
|
151 | 164 | Object.defineProperty(WINDOW, 'nw', { value: undefined, writable: true });
|
152 | 165 | Object.defineProperty(WINDOW, 'window', { value: WINDOW, writable: true });
|
| 166 | + vi.clearAllMocks(); |
153 | 167 | });
|
154 | 168 |
|
155 | 169 | it('logs a browser extension error if executed inside a Chrome extension', () => {
|
|
0 commit comments