{"id":18801860,"url":"https://github.com/mitscherlich/vitest-localstorage-mock","last_synced_at":"2025-04-13T17:32:25.221Z","repository":{"id":61115551,"uuid":"542163447","full_name":"Mitscherlich/vitest-localstorage-mock","owner":"Mitscherlich","description":"A module to mock window.localStorage and window.sessionStorage in Vitest","archived":false,"fork":false,"pushed_at":"2025-02-25T18:45:18.000Z","size":707,"stargazers_count":10,"open_issues_count":12,"forks_count":0,"subscribers_count":3,"default_branch":"dev","last_synced_at":"2025-02-26T09:41:34.050Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://npm.im/vitest-localstorage-mock","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Mitscherlich.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-27T15:41:13.000Z","updated_at":"2025-02-19T14:18:52.000Z","dependencies_parsed_at":"2024-05-29T04:59:21.524Z","dependency_job_id":"8da3f470-1296-47f7-bb23-c6958e7a2e9b","html_url":"https://github.com/Mitscherlich/vitest-localstorage-mock","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mitscherlich%2Fvitest-localstorage-mock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mitscherlich%2Fvitest-localstorage-mock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mitscherlich%2Fvitest-localstorage-mock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mitscherlich%2Fvitest-localstorage-mock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Mitscherlich","download_url":"https://codeload.github.com/Mitscherlich/vitest-localstorage-mock/tar.gz/refs/heads/dev","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248752533,"owners_count":21156109,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T22:25:32.238Z","updated_at":"2025-04-13T17:32:24.860Z","avatar_url":"https://github.com/Mitscherlich.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vitest-localstorage-mock\n\nAuto mock `localstorage` and `sessionstorage` in your [Vitest](https://vitest.dev/) scripts for testing.\n\n[![npm version](https://badgen.net/npm/v/vitest-localstorage-mock)](https://npm.im/vitest-localstorage-mock) [![npm downloads](https://badgen.net/npm/dm/vitest-localstorage-mock)](https://npm.im/vitest-localstorage-mock) ![actions status](https://github.com/Mitscherlich/vitest-localstorage-mock/actions/workflows/ci.yml/badge.svg?branch=dev)\n\n## Install\n\nvia `pnpm`, `yarn` or `npm`:\n\n```bash\npnpm add -D vitest-localstorage-mock\n# or\nyarn add -D vitest-localstorage-mock\n# or\nnpm install -D vitest-localstorage-mock\n```\n\n## Setup\n\n### Module\n\nIn your `vite.config.(js|ts)` under the `test` [configuration section](https://vitest.dev/config/#options) create a `setupFiles` array and add `vitest-localstorage-mock` to the array. ~~Also, ensure you have enabled [`globals`](https://vitest.dev/config/#globals)~~ We don't need globals any more.\n\n```js\nimport { defineConfig } from 'vite'\n\nexport default defineConfig({\n  test: {\n    setupFiles: ['vitest-localstorage-mock'],\n    mockReset: false,\n  }\n})\n```\n\n### Setup file\n\nAlternatively you can create a new setup file which then requires this module or\nadd the `require` statement to an existing setup file.\n\n- `__setups__/localstorage.js`\n\n```js\nimport 'vitest-localstorage-mock'\n```\n\nAdd that file to your `setupFiles` array:\n\n```js\nimport { defineConfig } from 'vite'\n\nexport default defineConfig({\n  test: {\n    setupFiles: ['./__setups__/localstorage.js'],\n    mockReset: false,\n  }\n})\n```\n\n## License\n\nMIT \u0026copy; [Mitscherlich](https://mitscherlich.me)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitscherlich%2Fvitest-localstorage-mock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmitscherlich%2Fvitest-localstorage-mock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitscherlich%2Fvitest-localstorage-mock/lists"}