1
1
import * as SentryBrowser from '@sentry/browser' ;
2
2
import { vi } from 'vitest' ;
3
- import { getDefaultIntegrations , init } from '../src/index ' ;
3
+ import { getDefaultIntegrations , init } from '../src/sdk ' ;
4
4
5
5
describe ( 'init' , ( ) => {
6
6
it ( 'sets the Angular version (if available) in the global scope' , ( ) => {
@@ -14,39 +14,16 @@ describe('init', () => {
14
14
expect ( setContextSpy ) . toHaveBeenCalledWith ( 'angular' , { version : 14 } ) ;
15
15
} ) ;
16
16
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 ( ) ;
19
22
20
- beforeEach ( ( ) => {
21
- browserInitSpy . mockClear ( ) ;
22
- } ) ;
23
+ const angularDefaultIntegrations = getDefaultIntegrations ( )
24
+ . map ( i => i . name )
25
+ . sort ( ) ;
23
26
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 ) ;
51
28
} ) ;
52
29
} ) ;
0 commit comments