Skip to content

Commit 4516b5a

Browse files
authored
Use Node 22 LTS and update tests to handle the new Navigation API (#519)
* Use Node 22 LTS locally * Drop Node 16 and add Node 22 in the builds * Handle Navigator API (Node 21+) * Handle logic in older Node versions
1 parent 656733c commit 4516b5a

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

.github/workflows/main.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ jobs:
129129

130130
strategy:
131131
matrix:
132-
node-version: [16, 18, 20]
132+
node-version: [18, 20, 22]
133133

134134
steps:
135135
- uses: actions/checkout@v3

.tool-versions

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
nodejs 20.16.0
1+
nodejs 20.9.0

integration-test/fake-clock-integration-test.js

+17-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ describe("withGlobal", function () {
5959
});
6060

6161
describe("globally configured browser objects", function () {
62-
let withGlobal, originalDescriptors;
62+
let withGlobal, originalDescriptors, originalNavigatorDescriptor;
6363

6464
// We use a set up function instead of beforeEach to avoid Mocha's check leaks detector
6565
function setUpGlobal() {
@@ -69,6 +69,11 @@ describe("globally configured browser objects", function () {
6969
);
7070
const window = dom.window;
7171

72+
originalNavigatorDescriptor = Object.getOwnPropertyDescriptor(
73+
global,
74+
"navigator",
75+
);
76+
7277
function makeMutable(descriptor) {
7378
descriptor.configurable = true;
7479
}
@@ -88,6 +93,8 @@ describe("globally configured browser objects", function () {
8893

8994
global.window = window;
9095
global.document = window.document;
96+
// navigator is a getter, so we need to remove it, as assigning does not work
97+
delete global.navigator;
9198
global.navigator = window.navigator;
9299
global.requestAnimationFrame = function (callback) {
93100
return setTimeout(callback, 0);
@@ -114,6 +121,15 @@ describe("globally configured browser objects", function () {
114121
delete global.navigator;
115122
delete global.requestAnimationFrame;
116123
delete global.cancelAnimationFrame;
124+
125+
// restore
126+
if (originalNavigatorDescriptor) {
127+
Object.defineProperty(
128+
global,
129+
"navigator",
130+
originalNavigatorDescriptor,
131+
);
132+
}
117133
}
118134

119135
it("correctly instantiates and tears down", function () {

0 commit comments

Comments
 (0)