From de5b0661e9ac43ca1042d53c2f40abdc6b706d4c Mon Sep 17 00:00:00 2001 From: Andrew Scott Date: Thu, 23 Oct 2025 15:40:42 -0700 Subject: [PATCH] fix(zone.js): Support jasmine v6 This fixes the jasmine patch to ensure we are patching the private APIs off of the right location, which changed in v6. see https://github.com/jasmine/jasmine/commit/168ff0a751b6280b170ce097410d77a4c7c1f449 (cherry picked from commit 48abe007d914626c6bb5f8fe17b3b07881221794) --- packages/zone.js/lib/jasmine/jasmine.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/zone.js/lib/jasmine/jasmine.ts b/packages/zone.js/lib/jasmine/jasmine.ts index 43b56d50ada..c8335d6331d 100644 --- a/packages/zone.js/lib/jasmine/jasmine.ts +++ b/packages/zone.js/lib/jasmine/jasmine.ts @@ -239,10 +239,15 @@ export function patchJasmine(Zone: ZoneType): void { timeout: {setTimeout: Function; clearTimeout: Function}; } type QueueRunnerUserContext = {queueRunner?: QueueRunner}; - const QueueRunner = (jasmine as any).QueueRunner as { + const j$ = jasmine as any; + const privateApis: { + QueueRunner: {}; + UserContext: new (...args: any[]) => QueueRunnerUserContext; + } = j$?.private?.QueueRunner ? j$?.private : j$; + const QueueRunner = privateApis.QueueRunner as { new (attrs: QueueRunnerAttrs): QueueRunner; }; - (jasmine as any).QueueRunner = (function (_super) { + privateApis.QueueRunner = (function (_super) { __extends(ZoneQueueRunner, _super); function ZoneQueueRunner(this: QueueRunner, attrs: QueueRunnerAttrs) { if (attrs.onComplete) { @@ -266,9 +271,9 @@ export function patchJasmine(Zone: ZoneType): void { // create a userContext to hold the queueRunner itself // so we can access the testProxy in it/xit/beforeEach ... - if ((jasmine as any).UserContext) { + if (privateApis.UserContext) { if (!attrs.userContext) { - attrs.userContext = new (jasmine as any).UserContext(); + attrs.userContext = new privateApis.UserContext(); } attrs.userContext.queueRunner = this; } else {