| 8 | |
| 9 | /** Gets whether the code is currently running in a test environment. */ |
| 10 | export function _isTestEnvironment(): boolean { |
| 11 | // We can't use `declare const` because it causes conflicts inside Google with the real typings |
| 12 | // for these symbols and we can't read them off the global object, because they don't appear to |
| 13 | // be attached there for some runners like Jest. |
| 14 | // (see: https://github.com/angular/components/issues/23365#issuecomment-938146643) |
| 15 | return ( |
| 16 | // @ts-ignore |
| 17 | (typeof __karma__ !== 'undefined' && !!__karma__) || |
| 18 | // @ts-ignore |
| 19 | (typeof jasmine !== 'undefined' && !!jasmine) || |
| 20 | // @ts-ignore |
| 21 | (typeof jest !== 'undefined' && !!jest) || |
| 22 | // @ts-ignore |
| 23 | (typeof Mocha !== 'undefined' && !!Mocha) |
| 24 | ); |
| 25 | } |