{"id":15369094,"url":"https://github.com/developit/jsdom-worker","last_synced_at":"2025-04-12T18:42:19.225Z","repository":{"id":28923413,"uuid":"119741128","full_name":"developit/jsdom-worker","owner":"developit","description":"👷‍♀️ Use Web Workers in Jest / JSDOM 🌈","archived":false,"fork":false,"pushed_at":"2023-04-06T08:37:17.000Z","size":204,"stargazers_count":289,"open_issues_count":12,"forks_count":20,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-04-03T21:11:49.991Z","etag":null,"topics":["jest","jest-environment","jest-plugin","jsdom","web-worker","webworker"],"latest_commit_sha":null,"homepage":"https://npm.im/jsdom-worker","language":"JavaScript","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/developit.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-01-31T20:44:22.000Z","updated_at":"2025-03-22T09:41:51.000Z","dependencies_parsed_at":"2024-06-18T13:37:02.146Z","dependency_job_id":"0f957ecf-785d-4d7d-bd93-ae97f843d116","html_url":"https://github.com/developit/jsdom-worker","commit_stats":{"total_commits":25,"total_committers":6,"mean_commits":4.166666666666667,"dds":0.56,"last_synced_commit":"aaf2874b87b4ab6d6d3113cd816e510d447331d3"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developit%2Fjsdom-worker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developit%2Fjsdom-worker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developit%2Fjsdom-worker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developit%2Fjsdom-worker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/developit","download_url":"https://codeload.github.com/developit/jsdom-worker/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248617100,"owners_count":21134189,"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","jest-environment","jest-plugin","jsdom","web-worker","webworker"],"created_at":"2024-10-01T13:34:07.232Z","updated_at":"2025-04-12T18:42:19.191Z","avatar_url":"https://github.com/developit.png","language":"JavaScript","readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://i.imgur.com/Xqla6Ia.jpg\" width=\"1100\"\u003e\n\u003c/p\u003e\n\n# jsdom-worker\n\n\u003e _Lets you use Web Workers in Jest!_\n\nThis is an experimental implementation of the Web Worker API (specifically Dedicated Worker) for JSDOM.\n\nIt does not currently do any real threading, rather it implements the `Worker` interface but all work is done in the current thread. `jsdom-worker` runs wherever JSDOM runs, and does not require Node.\n\nIt supports both \"inline\" _(created via Blob)_ and standard _(loaded via URL)_ workers.\n\n\u003e **Hot Take:** this module likely works in the browser, where it could act as a simple inline worker \"poorlyfill\".\n\n\u003ca href=\"https://www.npmjs.org/package/jsdom-worker\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/jsdom-worker.svg?style=flat\" alt=\"npm\"\u003e\u003c/a\u003e \u003ca href=\"https://travis-ci.org/developit/jsdom-worker\"\u003e\u003cimg src=\"https://travis-ci.org/developit/jsdom-worker.svg?branch=master\" alt=\"travis\"\u003e\u003c/a\u003e\n\n## Why?\n\nJest uses a JSDOM environment by default, which means it doesn't support Workers. This means it is impossible to test code that requires both NodeJS functionality _and_ Web Workers. `jsdom-worker` implements enough of the Worker spec that it is now possible to do so.\n\n## Installation\n\n`npm i jsdom-worker`\n\n## Example\n\n```js\nimport 'jsdom-global/register';\nimport 'jsdom-worker';\n\nlet code = `onmessage = e =\u003e postMessage(e.data*2)`;\nlet worker = new Worker(URL.createObjectURL(new Blob([code])));\nworker.onmessage = console.log;\nworker.postMessage(5); // 10\n```\n\n## Usage with Jest\n\nFor single tests, simply add `import 'jsdom-worker'` to your module.\n\nOtherwise, add it via the [setupFiles](https://facebook.github.io/jest/docs/en/configuration.html#setupfiles-array) Jest config option:\n\n```js\n{\n  \"setupFiles\": [\n    \"jsdom-worker\"\n  ]\n}\n```\n\n## License\n\n[MIT License](https://oss.ninja/mit/developit)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevelopit%2Fjsdom-worker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevelopit%2Fjsdom-worker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevelopit%2Fjsdom-worker/lists"}