Skip to content

Commit

Permalink
fix(tests): prevent overwriting navigator.userAgent
Browse files Browse the repository at this point in the history
This property has been made read-only in node 21.1.0
  • Loading branch information
mgermerie authored and Desplandis committed Jan 12, 2024
1 parent b118942 commit f146262
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions test/unit/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit f146262

Please sign in to comment.