{"id":22733306,"url":"https://github.com/evargast/mockrequestanimationframe","last_synced_at":"2025-03-30T01:45:15.190Z","repository":{"id":57300069,"uuid":"285424172","full_name":"evargast/MockRequestAnimationFrame","owner":"evargast","description":null,"archived":false,"fork":false,"pushed_at":"2022-10-06T18:51:15.000Z","size":539,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-24T04:30:04.563Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/evargast.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-08-05T23:13:49.000Z","updated_at":"2022-06-02T22:30:45.000Z","dependencies_parsed_at":"2022-08-26T18:12:45.604Z","dependency_job_id":null,"html_url":"https://github.com/evargast/MockRequestAnimationFrame","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evargast%2FMockRequestAnimationFrame","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evargast%2FMockRequestAnimationFrame/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evargast%2FMockRequestAnimationFrame/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evargast%2FMockRequestAnimationFrame/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/evargast","download_url":"https://codeload.github.com/evargast/MockRequestAnimationFrame/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246266250,"owners_count":20749754,"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-12-10T20:13:40.955Z","updated_at":"2025-03-30T01:45:15.166Z","avatar_url":"https://github.com/evargast.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mock Request Animation Frame\n\n\u003ca href=\"https://www.npmjs.com/package/mock-request-animation-frame\"\u003e\n    \u003cimg alt=\"npm\" src=\"https://img.shields.io/npm/v/mock-request-animation-frame.svg?style=flat-square\"\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://www.npmjs.com/package/mock-request-animation-frame\"\u003e\n    \u003cimg alt=\"npm\" src=\"https://img.shields.io/npm/dt/mock-request-animation-frame?style=flat-square\"\u003e\n\u003c/a\u003e\n\n## Installation\n\n```\nyarn add -D mock-request-animation-frame\n```\n\nor\n\n```\nnpm i -D mock-request-animation-frame\n```\n\n## Disclaimer\n\n_These helper functions are intended to be used with Jest._\n\n## Getting started\n\nThis module now comes with 2 helper functions! Specially designed for tests on components that use [Adobe React Spectrum](https://react-spectrum.adobe.com/react-spectrum/index.html).\n\n1. **mockRequestAnimationFrame** - It will fully mock a [request animation frame](https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame) (RAF). There are various components that leverage RAFs for rendering causing tests to break.\n\n2. **mockClientWindow** - It will mock the height and width of the window object. Some components need dimensions for rendering, also breaking jest tests if not mocked.\n\nYou will have to call this helper functions in **each test file** that will encounter a RAF or needs window dimensions while executing.\n\nBehind the scenes these functions use beforeEach, afterEach, beforeAll and afterAll thus it may be run at the top level of the file or at the top level of your `describe` statements see the examples below for more details.\n\n### Examples\n\n```javascript\n// one-of-your-test-files\nimport { mockRequestAnimationFrame } from \"mock-request-animation-frame\";\n\nmockRequestAnimationFrame();\n\n// Run your tests here\n```\n\nor\n\n```javascript\nimport { mockClientWindow } from \"mock-request-animation-frame\";\n\ndescribe(\"example test\", () =\u003e {\n    mockClientWindow();\n\n    // Run your tests here\n});\n```\n\n\u0026nbsp;\n\u0026nbsp;\n\u0026nbsp;\n\u0026nbsp;\n\n## \u003cdiv align=\"center\"\u003e Happy testing! 🔬\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevargast%2Fmockrequestanimationframe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fevargast%2Fmockrequestanimationframe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevargast%2Fmockrequestanimationframe/lists"}