diff --git a/docusaurus/docs/running-tests.md b/docusaurus/docs/running-tests.md index f43dd43b1a7..208f91bab46 100644 --- a/docusaurus/docs/running-tests.md +++ b/docusaurus/docs/running-tests.md @@ -238,13 +238,10 @@ For example: ### `src/setupTests.js` ```js -const localStorageMock = { - getItem: jest.fn(), - setItem: jest.fn(), - removeItem: jest.fn(), - clear: jest.fn(), -}; -global.localStorage = localStorageMock; +Storage.prototype.getItem = jest.fn() +Storage.prototype.setItem = jest.fn() +Storage.prototype.removeItem = jest.fn() +Storage.prototype.clear = jest.fn() ``` > Note: Keep in mind that if you decide to "eject" before creating `src/setupTests.js`, the resulting `package.json` file won't contain any reference to it, so you should manually create the property `setupTestFrameworkScriptFile` in the configuration for Jest, something like the following: