diff --git a/packages/zone.js/lib/jasmine/jasmine.ts b/packages/zone.js/lib/jasmine/jasmine.ts index 964caeefab..a141e6ee5f 100644 --- a/packages/zone.js/lib/jasmine/jasmine.ts +++ b/packages/zone.js/lib/jasmine/jasmine.ts @@ -204,12 +204,14 @@ (jasmine as any).QueueRunner = (function(_super) { __extends(ZoneQueueRunner, _super); function ZoneQueueRunner(attrs: QueueRunnerAttrs) { - attrs.onComplete = (fn => () => { - // All functions are done, clear the test zone. - this.testProxyZone = null; - this.testProxyZoneSpec = null; - ambientZone.scheduleMicroTask('jasmine.onComplete', fn); - })(attrs.onComplete); + if (attrs.onComplete) { + attrs.onComplete = (fn => () => { + // All functions are done, clear the test zone. + this.testProxyZone = null; + this.testProxyZoneSpec = null; + ambientZone.scheduleMicroTask('jasmine.onComplete', fn); + })(attrs.onComplete); + } const nativeSetTimeout = _global[Zone.__symbol__('setTimeout')]; const nativeClearTimeout = _global[Zone.__symbol__('clearTimeout')]; diff --git a/packages/zone.js/lib/zone.ts b/packages/zone.js/lib/zone.ts index 69f7a7c1ef..ac47db0dbf 100644 --- a/packages/zone.js/lib/zone.ts +++ b/packages/zone.js/lib/zone.ts @@ -1217,6 +1217,9 @@ const Zone: ZoneType = (function(global: any) { this.data = options; this.scheduleFn = scheduleFn; this.cancelFn = cancelFn; + if (!callback) { + throw new Error('callback is not defined'); + } this.callback = callback; const self = this; // TODO: @JiaLiPassion options should have interface