Added a note about correct usage of async matchers

This commit is contained in:
Steve Gravrock
2021-04-24 12:43:25 -07:00
parent d666f1efbb
commit 5e3f937221
2 changed files with 46 additions and 2 deletions

View File

@@ -3722,7 +3722,29 @@ getJasmineRequireObj().Expectation = function(j$) {
});
/**
* Asynchronous matchers.
* Asynchronous matchers that operate on an actual value which is a promise,
* and return a promise.
*
* Note: Specs must await the result of each async matcher, return the
* promise returned by the matcher, or return a promise that's derived from
* the one returned by the matcher. Otherwise the matcher will not be
* evaluated before the spec completes.
*
* @example
* // Good
* await expectAsync(aPromise).toBeResolved();
* @example
* // Good
* return expectAsync(aPromise).toBeResolved();
* @example
* // Good
* return expectAsync(aPromise).toBeResolved()
* .then(function() {
* // more spec code
* });
* @example
* // Bad
* expectAsync(aPromise).toBeResolved();
* @namespace async-matchers
*/
function AsyncExpectation(options) {

View File

@@ -43,7 +43,29 @@ getJasmineRequireObj().Expectation = function(j$) {
});
/**
* Asynchronous matchers.
* Asynchronous matchers that operate on an actual value which is a promise,
* and return a promise.
*
* Note: Specs must await the result of each async matcher, return the
* promise returned by the matcher, or return a promise that's derived from
* the one returned by the matcher. Otherwise the matcher will not be
* evaluated before the spec completes.
*
* @example
* // Good
* await expectAsync(aPromise).toBeResolved();
* @example
* // Good
* return expectAsync(aPromise).toBeResolved();
* @example
* // Good
* return expectAsync(aPromise).toBeResolved()
* .then(function() {
* // more spec code
* });
* @example
* // Bad
* expectAsync(aPromise).toBeResolved();
* @namespace async-matchers
*/
function AsyncExpectation(options) {