-
Notifications
You must be signed in to change notification settings - Fork 12k
@angular-devkit/build-angular
breaks Jasmine's mock clock
#11626
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I assume the fix would be just restoring the |
This might be the root cause of #11164 as well. |
Yes, I tried it and the proposed fix (reverting |
The is a bug in versions 0.6.8+ that breaks when trying to use Jasmine's mock clock. Related to angular/angular-cli#11626.
I have also confirmed that the proposed fix does affect the actual fix for #10485 (used the repro in #10485 (comment)). I will submit a PR. |
The is a bug in versions 0.6.8+ that breaks when trying to use Jasmine's mock clock. Related to angular/angular-cli#11626.
The is a bug in versions 0.6.8+ that breaks when trying to use Jasmine's mock clock. Related to angular/angular-cli#11626.
The is a bug in versions 0.6.8+ that breaks when trying to use Jasmine's mock clock. Related to angular/angular-cli#11626.
The is a bug in versions 0.6.8+ that breaks when trying to use Jasmine's mock clock. Related to angular/angular-cli#11626.
The is a bug in versions 0.6.8+ that breaks when trying to use Jasmine's mock clock. Related to angular/angular-cli#11626.
The is a bug in versions 0.6.8+ that breaks when trying to use Jasmine's mock clock. Related to angular/angular-cli#11626.
The is a bug in versions 0.6.8+ that breaks when trying to use Jasmine's mock clock. Related to angular/angular-cli#11626.
The is a bug in versions 0.6.8+ that breaks when trying to use Jasmine's mock clock. Related to angular/angular-cli#11626.
…19795) The is a bug in versions 0.6.8+ that breaks when trying to use Jasmine's mock clock. Related to angular/angular-cli#11626. PR Close #19795
The is a bug in versions 0.6.8+ that breaks when trying to use Jasmine's mock clock. Related to angular/angular-cli#11626.
The is a bug in versions 0.6.8+ that breaks when trying to use Jasmine's mock clock. Related to angular/angular-cli#11626.
The is a bug in versions 0.6.8+ that breaks when trying to use Jasmine's mock clock. Related to angular/angular-cli#11626.
The is a bug in versions 0.6.8+ that breaks when trying to use Jasmine's mock clock. Related to angular/angular-cli#11626.
…25997) The is a bug in versions 0.6.8+ that breaks when trying to use Jasmine's mock clock. Related to angular/angular-cli#11626. PR Close #25997
Turns out running with it('should do stuff', fakeAsync(() =>
jasmine.clock().install();
const baseTime: Date = new Date(2017, 3, 21);
jasmine.clock().mockDate(baseTime);
expect(...some-code...).toEqual('20170421');
)); but the actual outcome is Without Note: test worked in Angular 5 before I upgraded to Angular 7 |
…ngular#19795) The is a bug in versions 0.6.8+ that breaks when trying to use Jasmine's mock clock. Related to angular/angular-cli#11626. PR Close angular#19795
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Bug Report or Feature Request (mark with an
x
)Command (mark with an
x
)Versions
OS: Windows 10
Repro steps
npm install --global @angular/cli
.ng new test-app && cd test-app
.npm test
--> Passed ✔️src/app/app.component.spec.ts
that usesjasmine.clock().install()
. E.g.:npm test
--> Fails ❌The log given by the failure
Desired functionality
No errors 😁
Mention any other details that might be useful
AFAICT, the problem is caused by incorrect order of code execution. More specifically:
setTimeout
).jasmine.clock().install()
, it overwrites the timing functions with mocks.In order for this to work, Zone.js must patch the global functions before Jasmine stores the "original" global functions (to later compare them and determine if the clock is already installed). For some reason, it seems that Jasmine is storing the global functions before Zone.js has patched them. Then, once we call
jasmine.clock().install()
, Jasmine compares the orignal, unpatched global functions with the current global functions (which have since been patched by Zone.js) and finds that they are not the same (and throws).I have no idea why this is happening, but by trying out several versions I have found out this is broken in
@angular-devkit/build-angular
v0.6.8 (and all the way through v0.7.0-rc.3). The commit that broke it is 0b126f6 and more specifically this change.Reverting the
test
property back to also check!chunks.some(({ name }) => name === 'polyfills')
fixes the issue.The text was updated successfully, but these errors were encountered: