Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

fix($timeout): verifyNoPendingTasks() throws even for non-timeout pending tasks #14336

Closed
@gkalpak

Description

@gkalpak

Do you want to request a feature or report a bug?

Bug

What is the current behavior?

ngMock's $timeout.verifyNoPendingTasks() throws if there are deferred tasks that are not related to $timeout.
Reproduction

What is the expected behavior?

ngMock's $timeout.verifyNoPendingTasks() should not throw if there are deferred tasks that are not related to $timeout.

What is the motivation / use case for changing the behavior?

It makes it difficult/unintuitive to test code that uses $timeout wrt pending tasks.

Which versions of Angular, and which browser / OS are affected by this issue? Did this work in previous versions of Angular? Please also test with the latest stable and snapshot (https://code.angularjs.org/snapshot/) versions.

Angular versions: 1.4 and 1.5 (those I tested with, but should affect oldrer versions too)
Browsers: All

Other information (e.g. stacktraces, related issues, suggestions how to fix)

When this method was introduced (back in f0c6ebc), $timeout was probably the only service that used $browser.defer(), so all $browser.deferredFns came from $timeout (thus an non-empty array, meant pending timeouts).
This is no longer the case. E.g. $browser.defer() is used in $evalAsync() and $applyAsync(), which means it transitively used throughout Angular (in watchers, directives etc).

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions