![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
@vitest/web-worker
Advanced tools
Web Worker support for Vitest testing. Doesn't require JSDom.
Simulates Web Worker, but in the same thread.
Supported:
new Worker(path)
new SharedWorker(path)
import MyWorker from './worker?worker'
import MySharedWorker from './worker?sharedworker'
# with npm
npm install -D @vitest/web-worker
# with pnpm
pnpm install -D @vitest/web-worker
# with yarn
yarn add --dev @vitest/web-worker
Just import @vitest/web-worker
in your test file to test only in current suite.
Or add @vitest/web-worker
in your setupFiles
, if you want to have a global support.
import { defineConfig } from 'vitest/node'
export default defineConfig({
test: {
setupFiles: ['@vitest/web-worker'],
},
})
You can also import defineWebWorkers
from @vitest/web-worker/pure
to define workers, whenever you need:
import { defineWebWorkers } from '@vitest/web-worker/pure'
if (process.env.SUPPORT_WORKERS) {
defineWebWorkers({ clone: 'none' })
}
It accepts options:
clone
: 'native' | 'ponyfill' | 'none'
. Defines how should Worker
clone message, when transferring data. Applies only to Worker
communication. SharedWorker
uses MessageChannel
from Node's worker_threads
module, and is not configurable.Note Requires Node 17, if you want to use native
structuredClone
. Otherwise, it fallbacks to polyfill, if not specified asnone
. You can also configure this option withVITEST_WEB_WORKER_CLONE
environmental variable.
// worker.ts
self.onmessage = (e) => {
self.postMessage(`${e.data} world`)
}
// worker.test.ts
import '@vitest/web-worker'
import MyWorker from '../worker?worker'
let worker = new MyWorker()
// new Worker is also supported
worker = new Worker(new URL('../src/worker.ts', import.meta.url))
worker.postMessage('hello')
worker.onmessage = (e) => {
// e.data equals to 'hello world'
}
onmessage = () => {}
. Please, use self.onmessage = () => {}
.onconnect = () => {}
. Please, use self.onconnect = () => {}
.byteLength
.DEBUG=vitest:web-worker
environmental variable.FAQs
Web Worker support for testing in Vitest
The npm package @vitest/web-worker receives a total of 39,332 weekly downloads. As such, @vitest/web-worker popularity was classified as popular.
We found that @vitest/web-worker demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.