Skip to content
Advertisement

How can I force @angular/core to use the latest version of zone.js in its peerDependencies configuration?

This test passes but results in a problem:

JavaScript

There is an error that displays when running tests in Jasmine and it falsely indicates test failure:

JavaScript

The bug that causes this error is fixed in the latest version of zone.js according to this thread:

https://github.com/angular/angular/issues/45476

@angular/core depends on zone.js version 0.11.4 in its peerDependencies which is revealed in package-lock.json:

JavaScript

I believe that if I can force @angular/core to use the latest version of zone.js this error will stop appearing.

How can I force @angular/core to use a specific version of zone.js?

Advertisement

Answer

I don’t know if forcing @angular/core to use a specific version of zone.js is a good idea because a different version may fix this problem but it can create other problems. There could be a good reason that @angular/core wants that version of zone.js.

To fix your issue, usually in Angular unit tests, I make sure I unsubscribe from the subscriptions especially if they are not one and done.

Try something like this to fix your issue:

JavaScript

The take(1) operator will only take one emission and call the callback and therefore done() should only be called once.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement