{"id":16476984,"url":"https://github.com/agilgur5/window-resizeto","last_synced_at":"2025-06-13T14:10:37.281Z","repository":{"id":65412571,"uuid":"244832211","full_name":"agilgur5/window-resizeto","owner":"agilgur5","description":"A window.resizeTo polyfill for test environments like Jest \u0026 JSDOM (in \u003c10 LoC)","archived":false,"fork":false,"pushed_at":"2020-03-06T12:50:17.000Z","size":297,"stargazers_count":11,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-04T15:11:29.989Z","etag":null,"topics":["jest","jsdom","polyfill","ponyfill","resize","resizeto","test","testing","window"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/agilgur5.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-04T07:11:40.000Z","updated_at":"2023-04-21T01:21:30.000Z","dependencies_parsed_at":"2023-01-22T08:05:43.328Z","dependency_job_id":null,"html_url":"https://github.com/agilgur5/window-resizeto","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/agilgur5/window-resizeto","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agilgur5%2Fwindow-resizeto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agilgur5%2Fwindow-resizeto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agilgur5%2Fwindow-resizeto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agilgur5%2Fwindow-resizeto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/agilgur5","download_url":"https://codeload.github.com/agilgur5/window-resizeto/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agilgur5%2Fwindow-resizeto/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259659667,"owners_count":22891672,"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","jsdom","polyfill","ponyfill","resize","resizeto","test","testing","window"],"created_at":"2024-10-11T12:44:11.222Z","updated_at":"2025-06-13T14:10:37.247Z","avatar_url":"https://github.com/agilgur5.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# window-resizeto\n\n\u003c!-- releases / versioning --\u003e\n[![package-json](https://img.shields.io/github/package-json/v/agilgur5/window-resizeto.svg)](https://npmjs.org/package/window-resizeto)\n[![releases](https://img.shields.io/github/tag-pre/agilgur5/window-resizeto.svg)](https://github.com/agilgur5/window-resizeto/releases)\n[![commits](https://img.shields.io/github/commits-since/agilgur5/window-resizeto/latest.svg)](https://github.com/agilgur5/window-resizeto/commits/master)\n\u003cbr\u003e\u003c!-- downloads --\u003e\n[![dt](https://img.shields.io/npm/dt/window-resizeto.svg)](https://npmjs.org/package/window-resizeto)\n[![dy](https://img.shields.io/npm/dy/window-resizeto.svg)](https://npmjs.org/package/window-resizeto)\n[![dm](https://img.shields.io/npm/dm/window-resizeto.svg)](https://npmjs.org/package/window-resizeto)\n[![dw](https://img.shields.io/npm/dw/window-resizeto.svg)](https://npmjs.org/package/window-resizeto)\n\u003cbr\u003e\u003c!-- status / activity --\u003e\n[![typings](https://img.shields.io/npm/types/window-resizeto.svg)](https://github.com/agilgur5/window-resizeto/blob/master/src/index.tsx)\n[![build status](https://img.shields.io/travis/agilgur5/window-resizeto/master.svg)](https://travis-ci.org/agilgur5/window-resizeto)\n[![code coverage](https://img.shields.io/codecov/c/gh/agilgur5/window-resizeto/master.svg)](https://codecov.io/gh/agilgur5/window-resizeto)\n\u003cbr\u003e\n[![NPM](https://nodei.co/npm/window-resizeto.png?downloads=true\u0026downloadRank=true\u0026stars=true)](https://npmjs.org/package/window-resizeto)\n\u003cbr\u003e\nA [`window.resizeTo`](https://developer.mozilla.org/en-US/docs/Web/API/Window/resizeTo) polyfill for test environments like Jest \u0026 JSDOM.\n\n## Installation\n\n`npm i -D window-resizeto`\n\n## Usage\n\nThere are a few different ways you can use `window-resizeto`:\n\n- With Jest:\n\n  ```javascript\n  // jest.config.js\n  module.exports = {\n    setupFilesAfterEnv: [\n      // polyfill window.resizeTo\n      'window-resizeto/polyfill'\n    ]\n  }\n  ```\n\n  ```javascript\n  // some-test.spec.js\n  window.resizeTo(500, 500)\n  // window is now resize to 500x500\n  ```\n\n- Standalone with the polyfill:\n\n  ```javascript\n  import 'window-resizeto/polyfill'\n\n  window.resizeTo(500, 500)\n  // window is now resized to 500x500\n  ```\n\n- With the ponyfill:\n\n  ```javascript\n  import { resizeTo } from 'window-resizeto'\n\n  resizeTo(window, 500, 500)\n  // window is now resized to 500x500\n  ```\n\n## How it works\n\nBasically just sets the `window`'s `outerWidth`, `outerHeight`, `innerWidth`, `innerHeight`, and fires a `resize` event.\nThe source code is currently just \u003c10 LoC, so [take a look under the hood](./src/)! :)\n\n## Credits\n\nInspiration for creating this came from [`mq-polyfill`](https://github.com/bigslycat/mq-polyfill) and a few [other](https://spectrum.chat/testing-library/help-react/how-to-set-window-innerwidth-to-test-mobile~70aa9572-b7cc-4397-92f5-a09d75ed24b8?m=MTU1OTU5MTI2MTI0MQ==) code samples that are nearly exact replicas.\nI wanted a package I could re-use in my projects' tests instead of having to constantly create a helper file, and so `window-resizeto` was born!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagilgur5%2Fwindow-resizeto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fagilgur5%2Fwindow-resizeto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagilgur5%2Fwindow-resizeto/lists"}