diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f270a83..be7bfad 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -129,7 +129,7 @@ jobs: strategy: matrix: - node-version: [16, 18, 20] + node-version: [18, 20, 22] steps: - uses: actions/checkout@v3 diff --git a/.tool-versions b/.tool-versions index c2bc75a..c2ca3d3 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1 +1 @@ -nodejs 20.16.0 +nodejs 20.9.0 diff --git a/integration-test/fake-clock-integration-test.js b/integration-test/fake-clock-integration-test.js index cebfeea..c4e28cc 100644 --- a/integration-test/fake-clock-integration-test.js +++ b/integration-test/fake-clock-integration-test.js @@ -59,7 +59,7 @@ describe("withGlobal", function () { }); describe("globally configured browser objects", function () { - let withGlobal, originalDescriptors; + let withGlobal, originalDescriptors, originalNavigatorDescriptor; // We use a set up function instead of beforeEach to avoid Mocha's check leaks detector function setUpGlobal() { @@ -69,6 +69,11 @@ describe("globally configured browser objects", function () { ); const window = dom.window; + originalNavigatorDescriptor = Object.getOwnPropertyDescriptor( + global, + "navigator", + ); + function makeMutable(descriptor) { descriptor.configurable = true; } @@ -88,6 +93,8 @@ describe("globally configured browser objects", function () { global.window = window; global.document = window.document; + // navigator is a getter, so we need to remove it, as assigning does not work + delete global.navigator; global.navigator = window.navigator; global.requestAnimationFrame = function (callback) { return setTimeout(callback, 0); @@ -114,6 +121,15 @@ describe("globally configured browser objects", function () { delete global.navigator; delete global.requestAnimationFrame; delete global.cancelAnimationFrame; + + // restore + if (originalNavigatorDescriptor) { + Object.defineProperty( + global, + "navigator", + originalNavigatorDescriptor, + ); + } } it("correctly instantiates and tears down", function () {