From a6eb04d554f6319138f3f510b5cc9d9418c8e4d0 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Tue, 3 Dec 2024 23:23:25 -0800 Subject: [PATCH] Improve environment detection. --- src/lib/pool.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib/pool.ts b/src/lib/pool.ts index 6360bee..4c48300 100644 --- a/src/lib/pool.ts +++ b/src/lib/pool.ts @@ -1,7 +1,10 @@ // SPDX-FileCopyrightText: 2024 Chris Duncan // SPDX-License-Identifier: GPL-3.0-or-later -if (globalThis.Worker == null) { +/** +* Polyfill for window methods which do not exist when executing Node.js tests. +*/ +if (typeof window === 'undefined' && typeof self === 'undefined') { const { Worker } = await import('node:worker_threads') //@ts-expect-error Worker.prototype.addEventListener = Worker.prototype.addListener -- 2.34.1