@@ -69,7 +69,7 @@ function uninstallAutoChangeDetectionStatusHandler(fixture: ComponentFixture<unk
6969
7070/** Whether we are currently in the fake async zone. */
7171function isInFakeAsyncZone ( ) {
72- return Zone ! . current . get ( 'FakeAsyncTestZoneSpec' ) != null ;
72+ return typeof Zone !== 'undefined' && Zone ! . current . get ( 'FakeAsyncTestZoneSpec' ) != null ;
7373}
7474
7575/**
@@ -91,7 +91,7 @@ export class TestbedHarnessEnvironment extends HarnessEnvironment<Element> {
9191 private _destroyed = false ;
9292
9393 /** Observable that emits whenever the test task state changes. */
94- private _taskState : Observable < TaskState > ;
94+ private _taskState ? : Observable < TaskState > ;
9595
9696 /** The options for this environment. */
9797 private _options : TestbedHarnessEnvironmentOptions ;
@@ -106,7 +106,9 @@ export class TestbedHarnessEnvironment extends HarnessEnvironment<Element> {
106106 ) {
107107 super ( rawRootElement ) ;
108108 this . _options = { ...defaultEnvironmentOptions , ...options } ;
109- this . _taskState = TaskStateZoneInterceptor . setup ( ) ;
109+ if ( typeof Zone !== 'undefined' ) {
110+ this . _taskState = TaskStateZoneInterceptor . setup ( ) ;
111+ }
110112 this . _stabilizeCallback = ( ) => this . forceStabilize ( ) ;
111113 installAutoChangeDetectionStatusHandler ( _fixture ) ;
112114 _fixture . componentRef . onDestroy ( ( ) => {
@@ -192,7 +194,7 @@ export class TestbedHarnessEnvironment extends HarnessEnvironment<Element> {
192194 // we cannot rely on "fixture.whenStable" since it does not catch tasks scheduled
193195 // outside of the Angular zone. For test harnesses, we want to ensure that the
194196 // app is fully stabilized and therefore need to use our own zone interceptor.
195- await this . _taskState . pipe ( takeWhile ( state => ! state . stable ) ) . toPromise ( ) ;
197+ await this . _taskState ? .pipe ( takeWhile ( state => ! state . stable ) ) . toPromise ( ) ;
196198 }
197199
198200 /** Gets the root element for the document. */
0 commit comments