From 0a4c8dbe45310bf0211af2db940b9322672468dc Mon Sep 17 00:00:00 2001 From: Pavel Mineev Date: Sun, 21 Feb 2021 23:55:46 +0300 Subject: [PATCH] clear localstorage-mock after each test --- frontend/app/__mocks__/localstorage.ts | 5 +++++ frontend/app/typings/jest-localstorage-mock.d.ts | 3 +++ frontend/jest.config.js | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 frontend/app/__mocks__/localstorage.ts create mode 100644 frontend/app/typings/jest-localstorage-mock.d.ts diff --git a/frontend/app/__mocks__/localstorage.ts b/frontend/app/__mocks__/localstorage.ts new file mode 100644 index 00000000..107cbe0b --- /dev/null +++ b/frontend/app/__mocks__/localstorage.ts @@ -0,0 +1,5 @@ +import 'jest-localstorage-mock'; + +afterEach(() => { + localStorage.clear(); +}); diff --git a/frontend/app/typings/jest-localstorage-mock.d.ts b/frontend/app/typings/jest-localstorage-mock.d.ts new file mode 100644 index 00000000..10b3192c --- /dev/null +++ b/frontend/app/typings/jest-localstorage-mock.d.ts @@ -0,0 +1,3 @@ +declare module 'jest-localstorage-mock' { + export const clear: () => void; +} diff --git a/frontend/jest.config.js b/frontend/jest.config.js index 8072c4aa..7409aa81 100644 --- a/frontend/jest.config.js +++ b/frontend/jest.config.js @@ -17,7 +17,7 @@ module.exports = { }, setupFiles: ['/jest.setup.ts'], setupFilesAfterEnv: [ - 'jest-localstorage-mock', + '/app/__mocks__/localstorage.ts', '/app/__mocks__/headers.ts', '/app/__stubs__/remark-config.ts', '/app/__stubs__/static-config.ts',