diff --git a/docs/MockFunctionAPI.md b/docs/MockFunctionAPI.md index fab938c6835c..b1b745738cee 100644 --- a/docs/MockFunctionAPI.md +++ b/docs/MockFunctionAPI.md @@ -296,6 +296,12 @@ jest.fn(function () { ### `mockFn.mockReturnValue(value)` +Shorthand for: + +```js +jest.fn().mockImplementation(() => value); +``` + Accepts a value that will be returned whenever the mock function is called. ```js tab @@ -320,6 +326,12 @@ mock(); // 43 ### `mockFn.mockReturnValueOnce(value)` +Shorthand for: + +```js +jest.fn().mockImplementationOnce(() => value); +``` + Accepts a value that will be returned for one call to the mock function. Can be chained so that successive calls to the mock function return different values. When there are no more `mockReturnValueOnce` values to use, calls will return a value specified by `mockReturnValue`. ```js tab diff --git a/website/versioned_docs/version-25.x/MockFunctionAPI.md b/website/versioned_docs/version-25.x/MockFunctionAPI.md index a38fb7823436..688d02de3ae0 100644 --- a/website/versioned_docs/version-25.x/MockFunctionAPI.md +++ b/website/versioned_docs/version-25.x/MockFunctionAPI.md @@ -210,6 +210,12 @@ jest.fn(function () { ### `mockFn.mockReturnValue(value)` +Shorthand for: + +```js +jest.fn().mockImplementation(() => value); +``` + Accepts a value that will be returned whenever the mock function is called. ```js @@ -222,6 +228,12 @@ mock(); // 43 ### `mockFn.mockReturnValueOnce(value)` +Shorthand for: + +```js +jest.fn().mockImplementationOnce(() => value); +``` + Accepts a value that will be returned for one call to the mock function. Can be chained so that successive calls to the mock function return different values. When there are no more `mockReturnValueOnce` values to use, calls will return a value specified by `mockReturnValue`. ```js diff --git a/website/versioned_docs/version-26.x/MockFunctionAPI.md b/website/versioned_docs/version-26.x/MockFunctionAPI.md index a38fb7823436..688d02de3ae0 100644 --- a/website/versioned_docs/version-26.x/MockFunctionAPI.md +++ b/website/versioned_docs/version-26.x/MockFunctionAPI.md @@ -210,6 +210,12 @@ jest.fn(function () { ### `mockFn.mockReturnValue(value)` +Shorthand for: + +```js +jest.fn().mockImplementation(() => value); +``` + Accepts a value that will be returned whenever the mock function is called. ```js @@ -222,6 +228,12 @@ mock(); // 43 ### `mockFn.mockReturnValueOnce(value)` +Shorthand for: + +```js +jest.fn().mockImplementationOnce(() => value); +``` + Accepts a value that will be returned for one call to the mock function. Can be chained so that successive calls to the mock function return different values. When there are no more `mockReturnValueOnce` values to use, calls will return a value specified by `mockReturnValue`. ```js diff --git a/website/versioned_docs/version-27.x/MockFunctionAPI.md b/website/versioned_docs/version-27.x/MockFunctionAPI.md index 4a4023408653..b4bebe06c8c7 100644 --- a/website/versioned_docs/version-27.x/MockFunctionAPI.md +++ b/website/versioned_docs/version-27.x/MockFunctionAPI.md @@ -220,6 +220,12 @@ jest.fn(function () { ### `mockFn.mockReturnValue(value)` +Shorthand for: + +```js +jest.fn().mockImplementation(() => value); +``` + Accepts a value that will be returned whenever the mock function is called. ```js @@ -232,6 +238,12 @@ mock(); // 43 ### `mockFn.mockReturnValueOnce(value)` +Shorthand for: + +```js +jest.fn().mockImplementationOnce(() => value); +``` + Accepts a value that will be returned for one call to the mock function. Can be chained so that successive calls to the mock function return different values. When there are no more `mockReturnValueOnce` values to use, calls will return a value specified by `mockReturnValue`. ```js diff --git a/website/versioned_docs/version-28.x/MockFunctionAPI.md b/website/versioned_docs/version-28.x/MockFunctionAPI.md index 902a777f7464..33144e068b07 100644 --- a/website/versioned_docs/version-28.x/MockFunctionAPI.md +++ b/website/versioned_docs/version-28.x/MockFunctionAPI.md @@ -296,6 +296,12 @@ jest.fn(function () { ### `mockFn.mockReturnValue(value)` +Shorthand for: + +```js +jest.fn().mockImplementation(() => value); +``` + Accepts a value that will be returned whenever the mock function is called. ```js tab @@ -320,6 +326,12 @@ mock(); // 43 ### `mockFn.mockReturnValueOnce(value)` +Shorthand for: + +```js +jest.fn().mockImplementationOnce(() => value); +``` + Accepts a value that will be returned for one call to the mock function. Can be chained so that successive calls to the mock function return different values. When there are no more `mockReturnValueOnce` values to use, calls will return a value specified by `mockReturnValue`. ```js tab diff --git a/website/versioned_docs/version-29.0/MockFunctionAPI.md b/website/versioned_docs/version-29.0/MockFunctionAPI.md index 159435349188..7575f52897db 100644 --- a/website/versioned_docs/version-29.0/MockFunctionAPI.md +++ b/website/versioned_docs/version-29.0/MockFunctionAPI.md @@ -296,6 +296,12 @@ jest.fn(function () { ### `mockFn.mockReturnValue(value)` +Shorthand for: + +```js +jest.fn().mockImplementation(() => value); +``` + Accepts a value that will be returned whenever the mock function is called. ```js tab @@ -320,6 +326,12 @@ mock(); // 43 ### `mockFn.mockReturnValueOnce(value)` +Shorthand for: + +```js +jest.fn().mockImplementationOnce(() => value); +``` + Accepts a value that will be returned for one call to the mock function. Can be chained so that successive calls to the mock function return different values. When there are no more `mockReturnValueOnce` values to use, calls will return a value specified by `mockReturnValue`. ```js tab diff --git a/website/versioned_docs/version-29.1/MockFunctionAPI.md b/website/versioned_docs/version-29.1/MockFunctionAPI.md index 1dfccbeb9f28..ebe71c2cefff 100644 --- a/website/versioned_docs/version-29.1/MockFunctionAPI.md +++ b/website/versioned_docs/version-29.1/MockFunctionAPI.md @@ -296,6 +296,12 @@ jest.fn(function () { ### `mockFn.mockReturnValue(value)` +Shorthand for: + +```js +jest.fn().mockImplementation(() => value); +``` + Accepts a value that will be returned whenever the mock function is called. ```js tab @@ -320,6 +326,12 @@ mock(); // 43 ### `mockFn.mockReturnValueOnce(value)` +Shorthand for: + +```js +jest.fn().mockImplementationOnce(() => value); +``` + Accepts a value that will be returned for one call to the mock function. Can be chained so that successive calls to the mock function return different values. When there are no more `mockReturnValueOnce` values to use, calls will return a value specified by `mockReturnValue`. ```js tab diff --git a/website/versioned_docs/version-29.2/MockFunctionAPI.md b/website/versioned_docs/version-29.2/MockFunctionAPI.md index 1dfccbeb9f28..ebe71c2cefff 100644 --- a/website/versioned_docs/version-29.2/MockFunctionAPI.md +++ b/website/versioned_docs/version-29.2/MockFunctionAPI.md @@ -296,6 +296,12 @@ jest.fn(function () { ### `mockFn.mockReturnValue(value)` +Shorthand for: + +```js +jest.fn().mockImplementation(() => value); +``` + Accepts a value that will be returned whenever the mock function is called. ```js tab @@ -320,6 +326,12 @@ mock(); // 43 ### `mockFn.mockReturnValueOnce(value)` +Shorthand for: + +```js +jest.fn().mockImplementationOnce(() => value); +``` + Accepts a value that will be returned for one call to the mock function. Can be chained so that successive calls to the mock function return different values. When there are no more `mockReturnValueOnce` values to use, calls will return a value specified by `mockReturnValue`. ```js tab diff --git a/website/versioned_docs/version-29.3/MockFunctionAPI.md b/website/versioned_docs/version-29.3/MockFunctionAPI.md index 157b1e0b873b..4ae25af569db 100644 --- a/website/versioned_docs/version-29.3/MockFunctionAPI.md +++ b/website/versioned_docs/version-29.3/MockFunctionAPI.md @@ -296,6 +296,12 @@ jest.fn(function () { ### `mockFn.mockReturnValue(value)` +Shorthand for: + +```js +jest.fn().mockImplementation(() => value); +``` + Accepts a value that will be returned whenever the mock function is called. ```js tab @@ -320,6 +326,12 @@ mock(); // 43 ### `mockFn.mockReturnValueOnce(value)` +Shorthand for: + +```js +jest.fn().mockImplementationOnce(() => value); +``` + Accepts a value that will be returned for one call to the mock function. Can be chained so that successive calls to the mock function return different values. When there are no more `mockReturnValueOnce` values to use, calls will return a value specified by `mockReturnValue`. ```js tab