From 7a103c618e565e9ac30614be00c952bb78c719fa Mon Sep 17 00:00:00 2001 From: Nicolas Goutay Date: Wed, 28 Nov 2018 15:30:53 +0100 Subject: [PATCH] =?UTF-8?q?Update=20localStorage=20mock=20in=20=E2=80=9CRu?= =?UTF-8?q?nning=20Tests=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On a project running [redux-persist](https://github.com/rt2zz/redux-persist), declaring the current `localStorage` mock would yield warnings in tests, making them harder to visually grep: ![image](https://user-images.githubusercontent.com/2587348/49158354-3c3f0200-f322-11e8-825d-2a68e0760af1.png) Redux Persists checks for three methods to detect if `localStorage` is defined: `getItem`, `setItem` and `removeItem` ([see relevant code](https://github.com/rt2zz/redux-persist/blob/208c6b112ead87b3701dfacaae2cdbe78377775a/src/integration/getStoredStateMigrateV4.js#L31-L43)). I suggest adding a `removeItem` mock to the docs as it fixes the warnings in tests. --- docusaurus/docs/running-tests.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docusaurus/docs/running-tests.md b/docusaurus/docs/running-tests.md index ea1b32579f0..5f14b5eb0d6 100644 --- a/docusaurus/docs/running-tests.md +++ b/docusaurus/docs/running-tests.md @@ -239,6 +239,7 @@ For example: const localStorageMock = { getItem: jest.fn(), setItem: jest.fn(), + removeItem: jest.fn(), clear: jest.fn(), }; global.localStorage = localStorageMock;