diff --git a/docusaurus/docs/running-tests.md b/docusaurus/docs/running-tests.md index e33a4bf27f2..43b389f9128 100644 --- a/docusaurus/docs/running-tests.md +++ b/docusaurus/docs/running-tests.md @@ -242,7 +242,9 @@ const localStorageMock = { removeItem: jest.fn(), clear: jest.fn(), }; -global.localStorage = localStorageMock; +Object.defineProperty(global, 'localStorage', { + value: localStorageMock +}); ``` > 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: