{"id":13769732,"url":"https://github.com/jorisre/jest-wake-lock-mock","last_synced_at":"2025-04-22T19:49:11.476Z","repository":{"id":56295569,"uuid":"308973731","full_name":"jorisre/jest-wake-lock-mock","owner":"jorisre","description":"Mock Screen Wake Lock API `navigator.wakeLock` with ease and run your tests using Jest","archived":false,"fork":false,"pushed_at":"2020-12-01T21:04:29.000Z","size":366,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-17T15:37:08.554Z","etag":null,"topics":["jest","mock","nosleep","test","wakelock"],"latest_commit_sha":null,"homepage":"https://npm.im/jest-wake-lock-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/jorisre.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["jorisre"]}},"created_at":"2020-10-31T21:19:12.000Z","updated_at":"2024-12-09T16:18:24.000Z","dependencies_parsed_at":"2022-08-15T16:10:35.557Z","dependency_job_id":null,"html_url":"https://github.com/jorisre/jest-wake-lock-mock","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jorisre%2Fjest-wake-lock-mock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jorisre%2Fjest-wake-lock-mock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jorisre%2Fjest-wake-lock-mock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jorisre%2Fjest-wake-lock-mock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jorisre","download_url":"https://codeload.github.com/jorisre/jest-wake-lock-mock/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250313028,"owners_count":21410144,"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":["jest","mock","nosleep","test","wakelock"],"created_at":"2024-08-03T17:00:30.972Z","updated_at":"2025-04-22T19:49:11.437Z","avatar_url":"https://github.com/jorisre.png","language":"TypeScript","funding_links":["https://github.com/sponsors/jorisre"],"categories":["Packages"],"sub_categories":["Mocks"],"readme":"\u003ch1 align=\"center\"\u003eWelcome to jest-wake-lock-mock 👋\u003c/h1\u003e\n\u003cp\u003e\n  \u003cimg alt=\"npm\" src=\"https://img.shields.io/npm/v/jest-wake-lock-mock?style=for-the-badge\"\u003e\n  \u003cimg alt=\"GitHub Workflow Status\" src=\"https://img.shields.io/github/workflow/status/jorisre/jest-wake-lock-mock/CI?style=for-the-badge\"\u003e\n  \u003cimg alt=\"Codecov\" src=\"https://img.shields.io/codecov/c/github/jorisre/jest-wake-lock-mock?style=for-the-badge\u0026token=D75F3R5OEO\"\u003e\n  \u003ca href=\"https://github.com/jorisre/jest-wake-lock-mock/blob/master/LICENSE\" target=\"_blank\"\u003e\n    \u003cimg alt=\"License: MIT\" src=\"https://img.shields.io/github/license/jorisre/jest-wake-lock-mock?style=for-the-badge\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://twitter.com/_jorisre\" target=\"_blank\"\u003e\n    \u003cimg alt=\"Twitter: _jorisre\" src=\"https://img.shields.io/twitter/follow/_jorisre.svg?style=for-the-badge\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\u003e Mock [Screen Wake Lock API](https://w3c.github.io/screen-wake-lock/) _(`navigator.wakeLock`)_ with ease and run your tests using Jest\n\n### 🏠 [Homepage](https://github.com/jorisre/jest-wake-lock-mock#readme)\n\n## Prerequisites\n\n- node \u003e=10\n\n## Install\n\n```sh\nnpm i -D jest-wake-lock-mock\n# or\nyarn add -D jest-wake-lock-mock\n```\n\n## Usage\n\nIn your `jest.config.js` or `package.json` under `jest` section create a [`setupFiles`](https://jestjs.io/docs/en/configuration#setupfiles-array) array and add `jest-wake-lock-mock` to it.\n\n```js\n{\n  setupFiles: ['jest-wake-lock-mock'],\n  // jest config...\n}\n```\n\n## Tests\n\nWrite your tests with confidence using the same [Screen Wake Lock API](https://w3c.github.io/screen-wake-lock/) api as in the browser.\n\n**Example** ([More](https://github.com/jorisre/jest-wake-lock-mock/blob/master/test/jest-wake-lock-mock.test.ts)):\n\n```js\nconst requestWakeLock = async () =\u003e {\n  try {\n    const wakeLock = await navigator.wakeLock.request('screen');\n\n    return { wakeLock };\n  } catch (error) {\n    return { error };\n  }\n};\n\ntest('wakeLock request with success', async () =\u003e {\n  const { wakeLock, error } = await requestWakeLock(handleRelease);\n\n  expect(error).not.toBeDefined();\n  expect(wakeLock).toBeDefined();\n  expect(wakeLock?.type).toEqual('screen');\n  expect(wakeLock?.released).toBe(false);\n});\n```\n\n## Author\n\n👤 **Joris**\n\n- Twitter: [@\\_jorisre](https://twitter.com/_jorisre)\n- Github: [@jorisre](https://github.com/jorisre)\n\n## 🤝 Contributing\n\nContributions, issues and feature requests are welcome!\u003cbr /\u003eFeel free to check [issues page](https://github.com/jorisre/jest-wake-lock-mock/issues).\n\n## Show your support\n\nGive a ⭐️ if this project helped you!\n\n## 📝 License\n\nCopyright © 2020 [Joris](https://github.com/jorisre).\u003cbr /\u003e\nThis project is [MIT](https://github.com/jorisre/jest-wake-lock-mock/blob/master/LICENSE) licensed.\n\n---\n\n_This README was generated with ❤️ by [readme-md-generator](https://github.com/kefranabg/readme-md-generator)_\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjorisre%2Fjest-wake-lock-mock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjorisre%2Fjest-wake-lock-mock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjorisre%2Fjest-wake-lock-mock/lists"}