@@ -10,20 +10,27 @@ import {DOCUMENT} from '@angular/common';
10
10
import { Inject , Injectable , OnDestroy } from '@angular/core' ;
11
11
import { Platform } from '@angular/cdk/platform' ;
12
12
13
- declare const __karma__ : unknown ;
14
- declare const jasmine : unknown ;
15
- declare const jest : unknown ;
16
- declare const Mocha : unknown ;
13
+ // Avoid using `declare const` because it caused conflicts inside Google
14
+ // with the real typings for these symbols.
15
+ declare interface TestGlobals {
16
+ jasmine : unknown ;
17
+ __karma__ : unknown ;
18
+ jest : unknown ;
19
+ Mocha : unknown ;
20
+ }
21
+
22
+ const globalsForTest = window as { } as TestGlobals ;
17
23
18
24
/**
19
25
* Whether we're in a testing environment.
20
26
* TODO(crisbeto): remove this once we have an overlay testing module or Angular starts tearing
21
27
* down the testing `NgModule` (see https://github.com/angular/angular/issues/18831).
22
28
*/
23
- const isTestEnvironment = ( typeof __karma__ !== 'undefined' && ! ! __karma__ ) ||
24
- ( typeof jasmine !== 'undefined' && ! ! jasmine ) ||
25
- ( typeof jest !== 'undefined' && ! ! jest ) ||
26
- ( typeof Mocha !== 'undefined' && ! ! Mocha ) ;
29
+ const isTestEnvironment =
30
+ ( typeof globalsForTest . __karma__ !== 'undefined' && ! ! globalsForTest . __karma__ ) ||
31
+ ( typeof globalsForTest . jasmine !== 'undefined' && ! ! globalsForTest . jasmine ) ||
32
+ ( typeof globalsForTest . jest !== 'undefined' && ! ! globalsForTest . jest ) ||
33
+ ( typeof globalsForTest . Mocha !== 'undefined' && ! ! globalsForTest . Mocha ) ;
27
34
28
35
/** Container inside which all overlays will render. */
29
36
@Injectable ( { providedIn : 'root' } )
0 commit comments