diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index 1736f7c5..b1241da8 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -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) { diff --git a/src/core/Expectation.js b/src/core/Expectation.js index 940a8cfe..fb2bcf9e 100644 --- a/src/core/Expectation.js +++ b/src/core/Expectation.js @@ -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) {