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

docs(guide/Unit Testing): add info about promises #13975

Merged
merged 1 commit into from
Feb 8, 2016

Conversation

Narretz
Copy link
Contributor

@Narretz Narretz commented Feb 8, 2016

Related #1915


When testing promises, it's important to know that the resolution of promises is tied to the {@link ng.$rootScope.Scope#$digest digest cycle}.
That means a promise's `then`, `catch` and `finally` callback functions are only called after a digest has run.
In tests, you can trigger a digest by calling a scope's {@link ng.$rootScope.Scope#$apply `$apply`function}.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing whitespace before "function".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since many tests don't need a scope, I would say that the way to trigger a digest is by means of $rootScope.$digest(). I'm fine mentioning both was ($rootScope.$digest() and someScope.$apply()), but I would definitely mention the former.

@Narretz Narretz merged commit 17ba2a6 into angular:master Feb 8, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants