From 87a4259551eb51e3565b14343dbdf74cc97db343 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Mon, 18 Nov 2024 14:41:03 +0100 Subject: [PATCH] test: fix CI failure MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- scripts/runtime.js | 2 +- tests/utils/Utils.test.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/runtime.js b/scripts/runtime.js index d67b07ff..202187db 100644 --- a/scripts/runtime.js +++ b/scripts/runtime.js @@ -12,7 +12,7 @@ const isNode = globalThis.process?.release?.name === 'node' // eslint-disable-next-line n/no-unsupported-features/node-builtins const isWorkerd = globalThis.navigator?.userAgent === 'Cloudflare-Workers' // eslint-disable-next-line n/no-unsupported-features/node-builtins -const isBrowser = !!globalThis.navigator +const isBrowser = !!globalThis.window && !!globalThis.navigator export const runtime = (() => { if (isBun) return JSRuntime.bun diff --git a/tests/utils/Utils.test.ts b/tests/utils/Utils.test.ts index d7aebaca..c88baa0f 100644 --- a/tests/utils/Utils.test.ts +++ b/tests/utils/Utils.test.ts @@ -8,7 +8,7 @@ import { satisfies } from 'semver' import type { TimestampedData } from '../../src/types/index.js' -import { runtime, runtimes } from '../../scripts/runtime.js' +import { JSRuntime, runtime } from '../../scripts/runtime.js' import { Constants } from '../../src/utils/Constants.js' import { clone, @@ -296,7 +296,7 @@ await describe('Utils test suite', async () => { const date = new Date() expect(clone(date)).toStrictEqual(date) expect(clone(date) === date).toBe(false) - if (runtime === runtimes.node && satisfies(version, '>=22.0.0')) { + if (runtime === JSRuntime.node && satisfies(version, '>=22.0.0')) { const url = new URL('https://domain.tld') expect(() => clone(url)).toThrow(new Error('Cannot clone object of unsupported type.')) } -- 2.34.1