From 9301c73c53675f912b724025de2480b65a9d276e Mon Sep 17 00:00:00 2001 From: BIKI DAS Date: Wed, 3 Nov 2021 01:19:29 +0530 Subject: [PATCH] Correcting mockClear api docs (#12019) --- docs/JestObjectAPI.md | 2 +- docs/MockFunctionAPI.md | 10 ++-------- website/versioned_docs/version-25.x/JestObjectAPI.md | 2 +- website/versioned_docs/version-25.x/MockFunctionAPI.md | 10 ++-------- website/versioned_docs/version-26.x/JestObjectAPI.md | 2 +- website/versioned_docs/version-26.x/MockFunctionAPI.md | 10 ++-------- website/versioned_docs/version-27.0/JestObjectAPI.md | 2 +- website/versioned_docs/version-27.0/MockFunctionAPI.md | 10 ++-------- website/versioned_docs/version-27.1/JestObjectAPI.md | 2 +- website/versioned_docs/version-27.1/MockFunctionAPI.md | 10 ++-------- website/versioned_docs/version-27.2/JestObjectAPI.md | 2 +- website/versioned_docs/version-27.2/MockFunctionAPI.md | 10 ++-------- 12 files changed, 18 insertions(+), 54 deletions(-) diff --git a/docs/JestObjectAPI.md b/docs/JestObjectAPI.md index 630e20b1dfc1..2c2e1b5bb5ed 100644 --- a/docs/JestObjectAPI.md +++ b/docs/JestObjectAPI.md @@ -556,7 +556,7 @@ test('plays audio', () => { ### `jest.clearAllMocks()` -Clears the `mock.calls` and `mock.instances` properties of all mocks. Equivalent to calling [`.mockClear()`](MockFunctionAPI.md#mockfnmockclear) on every mocked function. +Clears the `mock.calls`, `mock.instances` and `mock.results` properties of all mocks. Equivalent to calling [`.mockClear()`](MockFunctionAPI.md#mockfnmockclear) on every mocked function. Returns the `jest` object for chaining. diff --git a/docs/MockFunctionAPI.md b/docs/MockFunctionAPI.md index b32c3827ae6e..aec58045feea 100644 --- a/docs/MockFunctionAPI.md +++ b/docs/MockFunctionAPI.md @@ -81,13 +81,9 @@ mockFn.mock.instances[1] === b; // true ### `mockFn.mockClear()` -Resets all information stored in the [`mockFn.mock.calls`](#mockfnmockcalls) and [`mockFn.mock.instances`](#mockfnmockinstances) arrays. +Resets all information stored in the [`mockFn.mock.calls`](#mockfnmockcalls), [`mockFn.mock.instances`](#mockfnmockinstances) and [`mockFn.mock.results`](#mockfnmockresults) arrays. Often this is useful when you want to clean up a mocks usage data between two assertions. -Often this is useful when you want to clean up a mocks usage data between two assertions. - -Beware that `mockClear` will replace `mockFn.mock`, not just [`mockFn.mock.calls`](#mockfnmockcalls) and [`mockFn.mock.instances`](#mockfnmockinstances). You should, therefore, avoid assigning `mockFn.mock` to other variables, temporary or not, to make sure you don't access stale data. - -The [`clearMocks`](configuration#clearmocks-boolean) configuration option is available to clear mocks automatically between tests. +Beware that `mockClear` will replace `mockFn.mock`, not just these three properties! You should, therefore, avoid assigning `mockFn.mock` to other variables, temporary or not, to make sure you don't access stale data. The [`clearMocks`](configuration#clearmocks-boolean) configuration option is available to clear mocks automatically between tests. ### `mockFn.mockReset()` @@ -95,8 +91,6 @@ Does everything that [`mockFn.mockClear()`](#mockfnmockclear) does, and also rem This is useful when you want to completely reset a _mock_ back to its initial state. (Note that resetting a _spy_ will result in a function with no return value). -Beware that `mockReset` will replace `mockFn.mock`, not just [`mockFn.mock.calls`](#mockfnmockcalls) and [`mockFn.mock.instances`](#mockfnmockinstances). You should, therefore, avoid assigning `mockFn.mock` to other variables, temporary or not, to make sure you don't access stale data. - ### `mockFn.mockRestore()` Does everything that [`mockFn.mockReset()`](#mockfnmockreset) does, and also restores the original (non-mocked) implementation. diff --git a/website/versioned_docs/version-25.x/JestObjectAPI.md b/website/versioned_docs/version-25.x/JestObjectAPI.md index 61c3885a65f5..45ffdd96b873 100644 --- a/website/versioned_docs/version-25.x/JestObjectAPI.md +++ b/website/versioned_docs/version-25.x/JestObjectAPI.md @@ -552,7 +552,7 @@ test('plays audio', () => { ### `jest.clearAllMocks()` -Clears the `mock.calls` and `mock.instances` properties of all mocks. Equivalent to calling [`.mockClear()`](MockFunctionAPI.md#mockfnmockclear) on every mocked function. +Clears the `mock.calls`, `mock.instances` and `mock.results` properties of all mocks. Equivalent to calling [`.mockClear()`](MockFunctionAPI.md#mockfnmockclear) on every mocked function. Returns the `jest` object for chaining. diff --git a/website/versioned_docs/version-25.x/MockFunctionAPI.md b/website/versioned_docs/version-25.x/MockFunctionAPI.md index b32c3827ae6e..aec58045feea 100644 --- a/website/versioned_docs/version-25.x/MockFunctionAPI.md +++ b/website/versioned_docs/version-25.x/MockFunctionAPI.md @@ -81,13 +81,9 @@ mockFn.mock.instances[1] === b; // true ### `mockFn.mockClear()` -Resets all information stored in the [`mockFn.mock.calls`](#mockfnmockcalls) and [`mockFn.mock.instances`](#mockfnmockinstances) arrays. +Resets all information stored in the [`mockFn.mock.calls`](#mockfnmockcalls), [`mockFn.mock.instances`](#mockfnmockinstances) and [`mockFn.mock.results`](#mockfnmockresults) arrays. Often this is useful when you want to clean up a mocks usage data between two assertions. -Often this is useful when you want to clean up a mocks usage data between two assertions. - -Beware that `mockClear` will replace `mockFn.mock`, not just [`mockFn.mock.calls`](#mockfnmockcalls) and [`mockFn.mock.instances`](#mockfnmockinstances). You should, therefore, avoid assigning `mockFn.mock` to other variables, temporary or not, to make sure you don't access stale data. - -The [`clearMocks`](configuration#clearmocks-boolean) configuration option is available to clear mocks automatically between tests. +Beware that `mockClear` will replace `mockFn.mock`, not just these three properties! You should, therefore, avoid assigning `mockFn.mock` to other variables, temporary or not, to make sure you don't access stale data. The [`clearMocks`](configuration#clearmocks-boolean) configuration option is available to clear mocks automatically between tests. ### `mockFn.mockReset()` @@ -95,8 +91,6 @@ Does everything that [`mockFn.mockClear()`](#mockfnmockclear) does, and also rem This is useful when you want to completely reset a _mock_ back to its initial state. (Note that resetting a _spy_ will result in a function with no return value). -Beware that `mockReset` will replace `mockFn.mock`, not just [`mockFn.mock.calls`](#mockfnmockcalls) and [`mockFn.mock.instances`](#mockfnmockinstances). You should, therefore, avoid assigning `mockFn.mock` to other variables, temporary or not, to make sure you don't access stale data. - ### `mockFn.mockRestore()` Does everything that [`mockFn.mockReset()`](#mockfnmockreset) does, and also restores the original (non-mocked) implementation. diff --git a/website/versioned_docs/version-26.x/JestObjectAPI.md b/website/versioned_docs/version-26.x/JestObjectAPI.md index e8deade705cd..62083e76c073 100644 --- a/website/versioned_docs/version-26.x/JestObjectAPI.md +++ b/website/versioned_docs/version-26.x/JestObjectAPI.md @@ -556,7 +556,7 @@ test('plays audio', () => { ### `jest.clearAllMocks()` -Clears the `mock.calls` and `mock.instances` properties of all mocks. Equivalent to calling [`.mockClear()`](MockFunctionAPI.md#mockfnmockclear) on every mocked function. +Clears the `mock.calls`, `mock.instances` and `mock.results` properties of all mocks. Equivalent to calling [`.mockClear()`](MockFunctionAPI.md#mockfnmockclear) on every mocked function. Returns the `jest` object for chaining. diff --git a/website/versioned_docs/version-26.x/MockFunctionAPI.md b/website/versioned_docs/version-26.x/MockFunctionAPI.md index b32c3827ae6e..aec58045feea 100644 --- a/website/versioned_docs/version-26.x/MockFunctionAPI.md +++ b/website/versioned_docs/version-26.x/MockFunctionAPI.md @@ -81,13 +81,9 @@ mockFn.mock.instances[1] === b; // true ### `mockFn.mockClear()` -Resets all information stored in the [`mockFn.mock.calls`](#mockfnmockcalls) and [`mockFn.mock.instances`](#mockfnmockinstances) arrays. +Resets all information stored in the [`mockFn.mock.calls`](#mockfnmockcalls), [`mockFn.mock.instances`](#mockfnmockinstances) and [`mockFn.mock.results`](#mockfnmockresults) arrays. Often this is useful when you want to clean up a mocks usage data between two assertions. -Often this is useful when you want to clean up a mocks usage data between two assertions. - -Beware that `mockClear` will replace `mockFn.mock`, not just [`mockFn.mock.calls`](#mockfnmockcalls) and [`mockFn.mock.instances`](#mockfnmockinstances). You should, therefore, avoid assigning `mockFn.mock` to other variables, temporary or not, to make sure you don't access stale data. - -The [`clearMocks`](configuration#clearmocks-boolean) configuration option is available to clear mocks automatically between tests. +Beware that `mockClear` will replace `mockFn.mock`, not just these three properties! You should, therefore, avoid assigning `mockFn.mock` to other variables, temporary or not, to make sure you don't access stale data. The [`clearMocks`](configuration#clearmocks-boolean) configuration option is available to clear mocks automatically between tests. ### `mockFn.mockReset()` @@ -95,8 +91,6 @@ Does everything that [`mockFn.mockClear()`](#mockfnmockclear) does, and also rem This is useful when you want to completely reset a _mock_ back to its initial state. (Note that resetting a _spy_ will result in a function with no return value). -Beware that `mockReset` will replace `mockFn.mock`, not just [`mockFn.mock.calls`](#mockfnmockcalls) and [`mockFn.mock.instances`](#mockfnmockinstances). You should, therefore, avoid assigning `mockFn.mock` to other variables, temporary or not, to make sure you don't access stale data. - ### `mockFn.mockRestore()` Does everything that [`mockFn.mockReset()`](#mockfnmockreset) does, and also restores the original (non-mocked) implementation. diff --git a/website/versioned_docs/version-27.0/JestObjectAPI.md b/website/versioned_docs/version-27.0/JestObjectAPI.md index 630e20b1dfc1..2c2e1b5bb5ed 100644 --- a/website/versioned_docs/version-27.0/JestObjectAPI.md +++ b/website/versioned_docs/version-27.0/JestObjectAPI.md @@ -556,7 +556,7 @@ test('plays audio', () => { ### `jest.clearAllMocks()` -Clears the `mock.calls` and `mock.instances` properties of all mocks. Equivalent to calling [`.mockClear()`](MockFunctionAPI.md#mockfnmockclear) on every mocked function. +Clears the `mock.calls`, `mock.instances` and `mock.results` properties of all mocks. Equivalent to calling [`.mockClear()`](MockFunctionAPI.md#mockfnmockclear) on every mocked function. Returns the `jest` object for chaining. diff --git a/website/versioned_docs/version-27.0/MockFunctionAPI.md b/website/versioned_docs/version-27.0/MockFunctionAPI.md index b32c3827ae6e..aec58045feea 100644 --- a/website/versioned_docs/version-27.0/MockFunctionAPI.md +++ b/website/versioned_docs/version-27.0/MockFunctionAPI.md @@ -81,13 +81,9 @@ mockFn.mock.instances[1] === b; // true ### `mockFn.mockClear()` -Resets all information stored in the [`mockFn.mock.calls`](#mockfnmockcalls) and [`mockFn.mock.instances`](#mockfnmockinstances) arrays. +Resets all information stored in the [`mockFn.mock.calls`](#mockfnmockcalls), [`mockFn.mock.instances`](#mockfnmockinstances) and [`mockFn.mock.results`](#mockfnmockresults) arrays. Often this is useful when you want to clean up a mocks usage data between two assertions. -Often this is useful when you want to clean up a mocks usage data between two assertions. - -Beware that `mockClear` will replace `mockFn.mock`, not just [`mockFn.mock.calls`](#mockfnmockcalls) and [`mockFn.mock.instances`](#mockfnmockinstances). You should, therefore, avoid assigning `mockFn.mock` to other variables, temporary or not, to make sure you don't access stale data. - -The [`clearMocks`](configuration#clearmocks-boolean) configuration option is available to clear mocks automatically between tests. +Beware that `mockClear` will replace `mockFn.mock`, not just these three properties! You should, therefore, avoid assigning `mockFn.mock` to other variables, temporary or not, to make sure you don't access stale data. The [`clearMocks`](configuration#clearmocks-boolean) configuration option is available to clear mocks automatically between tests. ### `mockFn.mockReset()` @@ -95,8 +91,6 @@ Does everything that [`mockFn.mockClear()`](#mockfnmockclear) does, and also rem This is useful when you want to completely reset a _mock_ back to its initial state. (Note that resetting a _spy_ will result in a function with no return value). -Beware that `mockReset` will replace `mockFn.mock`, not just [`mockFn.mock.calls`](#mockfnmockcalls) and [`mockFn.mock.instances`](#mockfnmockinstances). You should, therefore, avoid assigning `mockFn.mock` to other variables, temporary or not, to make sure you don't access stale data. - ### `mockFn.mockRestore()` Does everything that [`mockFn.mockReset()`](#mockfnmockreset) does, and also restores the original (non-mocked) implementation. diff --git a/website/versioned_docs/version-27.1/JestObjectAPI.md b/website/versioned_docs/version-27.1/JestObjectAPI.md index 630e20b1dfc1..2c2e1b5bb5ed 100644 --- a/website/versioned_docs/version-27.1/JestObjectAPI.md +++ b/website/versioned_docs/version-27.1/JestObjectAPI.md @@ -556,7 +556,7 @@ test('plays audio', () => { ### `jest.clearAllMocks()` -Clears the `mock.calls` and `mock.instances` properties of all mocks. Equivalent to calling [`.mockClear()`](MockFunctionAPI.md#mockfnmockclear) on every mocked function. +Clears the `mock.calls`, `mock.instances` and `mock.results` properties of all mocks. Equivalent to calling [`.mockClear()`](MockFunctionAPI.md#mockfnmockclear) on every mocked function. Returns the `jest` object for chaining. diff --git a/website/versioned_docs/version-27.1/MockFunctionAPI.md b/website/versioned_docs/version-27.1/MockFunctionAPI.md index b32c3827ae6e..aec58045feea 100644 --- a/website/versioned_docs/version-27.1/MockFunctionAPI.md +++ b/website/versioned_docs/version-27.1/MockFunctionAPI.md @@ -81,13 +81,9 @@ mockFn.mock.instances[1] === b; // true ### `mockFn.mockClear()` -Resets all information stored in the [`mockFn.mock.calls`](#mockfnmockcalls) and [`mockFn.mock.instances`](#mockfnmockinstances) arrays. +Resets all information stored in the [`mockFn.mock.calls`](#mockfnmockcalls), [`mockFn.mock.instances`](#mockfnmockinstances) and [`mockFn.mock.results`](#mockfnmockresults) arrays. Often this is useful when you want to clean up a mocks usage data between two assertions. -Often this is useful when you want to clean up a mocks usage data between two assertions. - -Beware that `mockClear` will replace `mockFn.mock`, not just [`mockFn.mock.calls`](#mockfnmockcalls) and [`mockFn.mock.instances`](#mockfnmockinstances). You should, therefore, avoid assigning `mockFn.mock` to other variables, temporary or not, to make sure you don't access stale data. - -The [`clearMocks`](configuration#clearmocks-boolean) configuration option is available to clear mocks automatically between tests. +Beware that `mockClear` will replace `mockFn.mock`, not just these three properties! You should, therefore, avoid assigning `mockFn.mock` to other variables, temporary or not, to make sure you don't access stale data. The [`clearMocks`](configuration#clearmocks-boolean) configuration option is available to clear mocks automatically between tests. ### `mockFn.mockReset()` @@ -95,8 +91,6 @@ Does everything that [`mockFn.mockClear()`](#mockfnmockclear) does, and also rem This is useful when you want to completely reset a _mock_ back to its initial state. (Note that resetting a _spy_ will result in a function with no return value). -Beware that `mockReset` will replace `mockFn.mock`, not just [`mockFn.mock.calls`](#mockfnmockcalls) and [`mockFn.mock.instances`](#mockfnmockinstances). You should, therefore, avoid assigning `mockFn.mock` to other variables, temporary or not, to make sure you don't access stale data. - ### `mockFn.mockRestore()` Does everything that [`mockFn.mockReset()`](#mockfnmockreset) does, and also restores the original (non-mocked) implementation. diff --git a/website/versioned_docs/version-27.2/JestObjectAPI.md b/website/versioned_docs/version-27.2/JestObjectAPI.md index 630e20b1dfc1..2c2e1b5bb5ed 100644 --- a/website/versioned_docs/version-27.2/JestObjectAPI.md +++ b/website/versioned_docs/version-27.2/JestObjectAPI.md @@ -556,7 +556,7 @@ test('plays audio', () => { ### `jest.clearAllMocks()` -Clears the `mock.calls` and `mock.instances` properties of all mocks. Equivalent to calling [`.mockClear()`](MockFunctionAPI.md#mockfnmockclear) on every mocked function. +Clears the `mock.calls`, `mock.instances` and `mock.results` properties of all mocks. Equivalent to calling [`.mockClear()`](MockFunctionAPI.md#mockfnmockclear) on every mocked function. Returns the `jest` object for chaining. diff --git a/website/versioned_docs/version-27.2/MockFunctionAPI.md b/website/versioned_docs/version-27.2/MockFunctionAPI.md index b32c3827ae6e..aec58045feea 100644 --- a/website/versioned_docs/version-27.2/MockFunctionAPI.md +++ b/website/versioned_docs/version-27.2/MockFunctionAPI.md @@ -81,13 +81,9 @@ mockFn.mock.instances[1] === b; // true ### `mockFn.mockClear()` -Resets all information stored in the [`mockFn.mock.calls`](#mockfnmockcalls) and [`mockFn.mock.instances`](#mockfnmockinstances) arrays. +Resets all information stored in the [`mockFn.mock.calls`](#mockfnmockcalls), [`mockFn.mock.instances`](#mockfnmockinstances) and [`mockFn.mock.results`](#mockfnmockresults) arrays. Often this is useful when you want to clean up a mocks usage data between two assertions. -Often this is useful when you want to clean up a mocks usage data between two assertions. - -Beware that `mockClear` will replace `mockFn.mock`, not just [`mockFn.mock.calls`](#mockfnmockcalls) and [`mockFn.mock.instances`](#mockfnmockinstances). You should, therefore, avoid assigning `mockFn.mock` to other variables, temporary or not, to make sure you don't access stale data. - -The [`clearMocks`](configuration#clearmocks-boolean) configuration option is available to clear mocks automatically between tests. +Beware that `mockClear` will replace `mockFn.mock`, not just these three properties! You should, therefore, avoid assigning `mockFn.mock` to other variables, temporary or not, to make sure you don't access stale data. The [`clearMocks`](configuration#clearmocks-boolean) configuration option is available to clear mocks automatically between tests. ### `mockFn.mockReset()` @@ -95,8 +91,6 @@ Does everything that [`mockFn.mockClear()`](#mockfnmockclear) does, and also rem This is useful when you want to completely reset a _mock_ back to its initial state. (Note that resetting a _spy_ will result in a function with no return value). -Beware that `mockReset` will replace `mockFn.mock`, not just [`mockFn.mock.calls`](#mockfnmockcalls) and [`mockFn.mock.instances`](#mockfnmockinstances). You should, therefore, avoid assigning `mockFn.mock` to other variables, temporary or not, to make sure you don't access stale data. - ### `mockFn.mockRestore()` Does everything that [`mockFn.mockReset()`](#mockfnmockreset) does, and also restores the original (non-mocked) implementation.