@@ -10,20 +10,29 @@ 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. We use `declare interface` instead
15
+ // of just `interface` for interop with Closure Compiler (prevents property renaming):
16
+ // https://github.com/angular/tsickle/blob/master/README.md#differences-from-typescript
17
+ declare interface TestGlobals {
18
+ jasmine : unknown ;
19
+ __karma__ : unknown ;
20
+ jest : unknown ;
21
+ Mocha : unknown ;
22
+ }
23
+
24
+ const globalsForTest = ( typeof window !== 'undefined' ? window : { } ) as { } as TestGlobals ;
17
25
18
26
/**
19
27
* Whether we're in a testing environment.
20
28
* TODO(crisbeto): remove this once we have an overlay testing module or Angular starts tearing
21
29
* down the testing `NgModule` (see https://github.com/angular/angular/issues/18831).
22
30
*/
23
- const isTestEnvironment = ( typeof __karma__ !== 'undefined' && ! ! __karma__ ) ||
24
- ( typeof jasmine !== 'undefined' && ! ! jasmine ) ||
25
- ( typeof jest !== 'undefined' && ! ! jest ) ||
26
- ( typeof Mocha !== 'undefined' && ! ! Mocha ) ;
31
+ const isTestEnvironment =
32
+ ( typeof globalsForTest . __karma__ !== 'undefined' && ! ! globalsForTest . __karma__ ) ||
33
+ ( typeof globalsForTest . jasmine !== 'undefined' && ! ! globalsForTest . jasmine ) ||
34
+ ( typeof globalsForTest . jest !== 'undefined' && ! ! globalsForTest . jest ) ||
35
+ ( typeof globalsForTest . Mocha !== 'undefined' && ! ! globalsForTest . Mocha ) ;
27
36
28
37
/** Container inside which all overlays will render. */
29
38
@Injectable ( { providedIn : 'root' } )
0 commit comments