You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is an experimental implementation of the Web Worker API (specifically Dedicated Worker) for JSDOM.
11
10
12
-
It 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.
11
+
It 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.
13
12
14
13
It supports both "inline" _(created via Blob)_ and standard _(loaded via URL)_ workers.
15
14
16
15
> **Hot Take:** this module likely works in the browser, where it could act as a simple inline worker "poorlyfill".
Jest 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.
21
+
Jest 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.
24
22
25
23
## Installation
26
24
@@ -29,13 +27,13 @@ Jest uses a JSDOM environment by default, which means it doesn't support Workers
29
27
## Example
30
28
31
29
```js
32
-
import'jsdom-global/register'
33
-
import'jsdom-worker'
30
+
import'jsdom-global/register';
31
+
import'jsdom-worker';
34
32
35
-
let code =`onmessage = e => postMessage(e.data*2)`
36
-
let worker =newWorker(URL.createObjectURL(newBlob([code])))
37
-
worker.onmessage=console.log
38
-
worker.postMessage(5)// 10
33
+
let code =`onmessage = e => postMessage(e.data*2)`;
34
+
let worker =newWorker(URL.createObjectURL(newBlob([code])));
0 commit comments