diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index b6bd9040..b1782efd 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -2801,10 +2801,25 @@ getJasmineRequireObj().Expectation = function(j$) { } } + /** + * Add some context for an {@link expect} + * @function + * @name matchers#withContext + * @param {String} message - Additional context to show when the matcher fails + * @return {matchers} + */ Expectation.prototype.withContext = function withContext(message) { return addFilter(this, new ContextAddingFilter(message)); }; + /** + * Invert the matcher following this {@link expect} + * @member + * @name matchers#not + * @type {matchers} + * @example + * expect(something).not.toBe(true); + */ Object.defineProperty(Expectation.prototype, 'not', { get: function() { return addFilter(this, syncNegatingFilter); @@ -2828,10 +2843,27 @@ getJasmineRequireObj().Expectation = function(j$) { } } + /** + * Add some context for an {@link expectAsync} + * @function + * @name async-matchers#withContext + * @param {String} message - Additional context to show when the async matcher fails + * @return {async-matchers} + */ AsyncExpectation.prototype.withContext = function withContext(message) { return addFilter(this, new ContextAddingFilter(message)); }; + /** + * Invert the matcher following this {@link expectAsync} + * @member + * @name async-matchers#not + * @type {async-matchers} + * @example + * await expectAsync(myPromise).not.toBeResolved(); + * @example + * return expectAsync(myPromise).not.toBeResolved(); + */ Object.defineProperty(AsyncExpectation.prototype, 'not', { get: function() { return addFilter(this, asyncNegatingFilter); diff --git a/src/core/Expectation.js b/src/core/Expectation.js index 34f777a4..2de1c15f 100644 --- a/src/core/Expectation.js +++ b/src/core/Expectation.js @@ -16,10 +16,25 @@ getJasmineRequireObj().Expectation = function(j$) { } } + /** + * Add some context for an {@link expect} + * @function + * @name matchers#withContext + * @param {String} message - Additional context to show when the matcher fails + * @return {matchers} + */ Expectation.prototype.withContext = function withContext(message) { return addFilter(this, new ContextAddingFilter(message)); }; + /** + * Invert the matcher following this {@link expect} + * @member + * @name matchers#not + * @type {matchers} + * @example + * expect(something).not.toBe(true); + */ Object.defineProperty(Expectation.prototype, 'not', { get: function() { return addFilter(this, syncNegatingFilter); @@ -43,10 +58,27 @@ getJasmineRequireObj().Expectation = function(j$) { } } + /** + * Add some context for an {@link expectAsync} + * @function + * @name async-matchers#withContext + * @param {String} message - Additional context to show when the async matcher fails + * @return {async-matchers} + */ AsyncExpectation.prototype.withContext = function withContext(message) { return addFilter(this, new ContextAddingFilter(message)); }; + /** + * Invert the matcher following this {@link expectAsync} + * @member + * @name async-matchers#not + * @type {async-matchers} + * @example + * await expectAsync(myPromise).not.toBeResolved(); + * @example + * return expectAsync(myPromise).not.toBeResolved(); + */ Object.defineProperty(AsyncExpectation.prototype, 'not', { get: function() { return addFilter(this, asyncNegatingFilter);