A Jest transformer for Webpack worker-loader that enables testing Web Workers with Jest. This package transforms worker files (matched by regex) into mock workers that emulate the Worker API, allowing tests to run in Node.js without a browser environment. Inspired by jsdom-worker. Current version 0.1.0 is unstable and experimental; the project is seeking maintainers. Key differentiators: specifically designed for worker-loader, uses a lightweight mock with terminate/close semantics.
npm install workerloader-jest-transformerVerified import paths — ran on the pinned version, not inferred.
Shows how to configure jest transform and test a web worker that doubles a number.
Consider alternatives like jsdom-worker or manual worker mocking for production.
Fork the repository or migrate to maintained alternatives.
Ensure your webpack config also includes worker-loader for non-test builds.
npm install --save-dev workerloader-jest-transformer
Ensure transform regex in jest config matches your worker files, e.g., '^.+\\.worker.[t|j]sx?$'