(worker: SharedWorker, msg: any)
| 279 | } |
| 280 | |
| 281 | function sendOnMessage(worker: SharedWorker, msg: any) { |
| 282 | return new Promise<string>((resolve, reject) => { |
| 283 | const timeout = setTimeout(() => { |
| 284 | reject(new Error(`Failed to send the message ${msg} to the SharedWorker.`)) |
| 285 | }, 5_000) |
| 286 | worker.port.onmessage = function onmessage(e) { |
| 287 | worker.port.onmessage = null |
| 288 | clearTimeout(timeout) |
| 289 | resolve(e.data as string) |
| 290 | } |
| 291 | worker.port.postMessage(msg) |
| 292 | }) |
| 293 | } |
| 294 | |
| 295 | it('vite shared worker works', async () => { |
| 296 | expect(MySharedWorker).toBeDefined() |
no test coverage detected