setupTests.js 375 B

12345678910111213141516171819202122
  1. import 'jsdom-global/register';
  2. // browserMocks.js
  3. const localStorageMock = (() => {
  4. let store = {};
  5. return {
  6. getItem(key) {
  7. return store[key] || null;
  8. },
  9. setItem(key, value) {
  10. store[key] = value.toString();
  11. },
  12. clear() {
  13. store = {};
  14. },
  15. };
  16. })();
  17. Object.defineProperty(window, 'localStorage', {
  18. value: localStorageMock,
  19. });