Skip to content

Commit 48abe00

Browse files
atscottcrisbeto
authored andcommitted
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 jasmine/jasmine@168ff0a
1 parent 07a5187 commit 48abe00

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

packages/zone.js/lib/jasmine/jasmine.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,15 @@ export function patchJasmine(Zone: ZoneType): void {
239239
timeout: {setTimeout: Function; clearTimeout: Function};
240240
}
241241
type QueueRunnerUserContext = {queueRunner?: QueueRunner};
242-
const QueueRunner = (jasmine as any).QueueRunner as {
242+
const j$ = jasmine as any;
243+
const privateApis: {
244+
QueueRunner: {};
245+
UserContext: new (...args: any[]) => QueueRunnerUserContext;
246+
} = j$?.private?.QueueRunner ? j$?.private : j$;
247+
const QueueRunner = privateApis.QueueRunner as {
243248
new (attrs: QueueRunnerAttrs): QueueRunner;
244249
};
245-
(jasmine as any).QueueRunner = (function (_super) {
250+
privateApis.QueueRunner = (function (_super) {
246251
__extends(ZoneQueueRunner, _super);
247252
function ZoneQueueRunner(this: QueueRunner, attrs: QueueRunnerAttrs) {
248253
if (attrs.onComplete) {
@@ -266,9 +271,9 @@ export function patchJasmine(Zone: ZoneType): void {
266271

267272
// create a userContext to hold the queueRunner itself
268273
// so we can access the testProxy in it/xit/beforeEach ...
269-
if ((jasmine as any).UserContext) {
274+
if (privateApis.UserContext) {
270275
if (!attrs.userContext) {
271-
attrs.userContext = new (jasmine as any).UserContext();
276+
attrs.userContext = new privateApis.UserContext();
272277
}
273278
attrs.userContext.queueRunner = this;
274279
} else {

0 commit comments

Comments
 (0)