From f146262ac98b0237c5256b11f6700f85794b47d5 Mon Sep 17 00:00:00 2001 From: mgermerie <73115044+mgermerie@users.noreply.github.com> Date: Tue, 9 Jan 2024 13:56:45 +0100 Subject: [PATCH] fix(tests): prevent overwriting `navigator.userAgent` This property has been made read-only in node 21.1.0 --- test/unit/bootstrap.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/test/unit/bootstrap.js b/test/unit/bootstrap.js index a6616899dd..961cdf348a 100644 --- a/test/unit/bootstrap.js +++ b/test/unit/bootstrap.js @@ -23,9 +23,13 @@ global.fetch = fetch; global.fetch.Promise = Promise; // this could be replaced by jsdom.Navigator in https://github.com/iTowns/itowns/pull/1412 -global.navigator = { - userAgent: 'firefox', -}; +// Checking if global.navigator exists targets node versions <21.1.0. Since node +// <21.1.0, global.navigator is read-only. +if (!global.navigator) { + global.navigator = { + userAgent: 'firefox', + }; +} class DOMElement { constructor() {