-
Notifications
You must be signed in to change notification settings - Fork 27.4k
1.6.2 - mocking $window in unit tests throws undefined is not an object (evaluating '$window.angular.callbacks') #15685
Comments
Can you provide a reproduction. We haven't changed anything wrt to mocking |
Sure thing, I'm not too sure how I'd do this in a plunker, is a runnable repo ok? |
It's OK. I have a minimal reproduction (based on an early prototype from @tommck). describe('My Angular App', function() {
beforeEach(module(function($provide) {
$provide.value('$window', {});
}));
it('should redirect to the configured URL on post-logout', inject(function($http) {
expect(true).toBeTruthy();
}));
}); Not sure what causes it yet. Looking into it. |
I think it is this commit. Previously, Since the real |
Note: for support questions, please use one of these channels: https://github.com/angular/angular.js/blob/master/CONTRIBUTING.md#question. This repository's issues are reserved for feature requests and bug reports.
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
1.6.2 only - if you mock the
$window
object in tests angular throws the errorIf the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://plnkr.co or similar (template: http://plnkr.co/edit/tpl:yBpEi4).
Mock out the $window like so:
Any tests that you try to run after this throw that error. This was working OK in < 1.6.2.
What is the expected behavior?
It should be possible to mock out the $window object in tests.
What is the motivation / use case for changing the behavior?
$window exists so that you can mock it.
Which versions of AngularJS, and which browser / OS are affected by this issue? Did this work in previous versions of AngularJS? Please also test with the latest stable and snapshot (https://code.angularjs.org/snapshot/) versions.
1.6.2 only
Other information (e.g. stacktraces, related issues, suggestions how to fix)
I guess it was caused by this commit: 0377c6f
The text was updated successfully, but these errors were encountered: