diff --git a/CHANGES.md b/CHANGES.md index c3bfb15..16c212f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,7 +7,7 @@ but this file may sometimes contain later improvements (e.g. typo fixes). ## next (not yet released) -No changes yet. +- Updated dependencies. ## v0.8.4 (2024-09-22) diff --git a/package-lock.json b/package-lock.json index b06896f..d140dbc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,7 @@ "undici": "^6.12.0" }, "devDependencies": { - "@sinonjs/fake-timers": "^12.0.0", + "@sinonjs/fake-timers": "^13.0.2", "chai": "^5.1.0", "chai-as-promised": "^8.0.0", "eslint": "^8.57.0", @@ -370,9 +370,9 @@ } }, "node_modules/@sinonjs/fake-timers": { - "version": "12.0.0", - "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-12.0.0.tgz", - "integrity": "sha512-bockPohsu/W5uL2w7km2fQcLBm0hi4k2h6Z3/tfzNGQ2BTuFEhJoFrMMpmGAW7zHqop0wtuXDm/WHPNY6JLoHA==", + "version": "13.0.2", + "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-13.0.2.tgz", + "integrity": "sha512-4Bb+oqXZTSTZ1q27Izly9lv8B9dlV61CROxPiVtywwzv5SnytJqhvYe6FclHYuXml4cd1VHPo1zd5PmTeJozvA==", "dev": true, "license": "BSD-3-Clause", "dependencies": { diff --git a/package.json b/package.json index 8debc41..7fc80b0 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "undici": "^6.12.0" }, "devDependencies": { - "@sinonjs/fake-timers": "^12.0.0", + "@sinonjs/fake-timers": "^13.0.2", "chai": "^5.1.0", "chai-as-promised": "^8.0.0", "eslint": "^8.57.0", diff --git a/test/unit/core.test.js b/test/unit/core.test.js index 91e419e..9554898 100644 --- a/test/unit/core.test.js +++ b/test/unit/core.test.js @@ -378,7 +378,7 @@ describe( 'Session', () => { it( 'uses retry options for token request', async () => { const clock = FakeTimers.install(); - clock.tickAsync( 1000 ); // just so it doesn’t start at 0 + await clock.tickAsync( 1000 ); // just so it doesn’t start at 0 try { const expectedParams = { @@ -406,7 +406,7 @@ describe( 'Session', () => { retryAfterReadonlySeconds: 3, tokenType: 'csrf', } ); - clock.tickAsync( 5000 ); + await clock.tickAsync( 5000 ); await expect( promise ) .to.be.rejectedWith( ApiErrors ); } finally { @@ -638,6 +638,16 @@ describe( 'Session', () => { clock = FakeTimers.install(); } ); afterEach( () => { + /* + * For some reason, since @sinonjs/fake-timers v13, + * the first test in this block which runs (no matter which specific test it is) + * creates a Node-internal afterWriteTick microtask / job + * in between the test returning and the afterEach hook running, + * which fails the countTimers expectation below unless we run it first. + * It’s weird, but at least this keeps the tests working 🤷 + */ + clock.runMicrotasks(); + clock.uninstall(); expect( clock.countTimers() ).to.equal( 0 ); } ); @@ -651,7 +661,7 @@ describe( 'Session', () => { { response: { response: true } }, ] ); const promise = session.request( {} ); - clock.tickAsync( 60000 ); + await clock.tickAsync( 60000 ); const response = await promise; expect( response ).to.eql( { response: true } ); } ); @@ -682,7 +692,7 @@ describe( 'Session', () => { { response: { response: true } }, ] ); const promise = session.request( {} ); - clock.tickAsync( 65000 ); + await clock.tickAsync( 65000 ); const response = await promise; expect( response ).to.eql( { response: true } ); } ); @@ -699,7 +709,7 @@ describe( 'Session', () => { } }, ] ); const promise = session.request( {}, { maxRetriesSeconds: 5 } ); - clock.tickAsync( 5000 ); + await clock.tickAsync( 5000 ); await expect( promise ) .to.be.rejectedWith( ApiErrors ); } ); @@ -730,7 +740,7 @@ describe( 'Session', () => { { response: { response: true } }, ] ); const promise = session.request( {} ); - clock.tickAsync( 5000 ); + await clock.tickAsync( 5000 ); const response = await promise; expect( response ).to.eql( { response: true } ); } ); @@ -741,7 +751,7 @@ describe( 'Session', () => { { response: { response: true } }, ] ); const promise = session.request( {} ); - clock.tickAsync( 30000 ); + await clock.tickAsync( 30000 ); const response = await promise; expect( response ).to.eql( { response: true } ); } ); @@ -752,7 +762,7 @@ describe( 'Session', () => { { response: { response: true } }, ] ); const promise = session.request( {}, { retryAfterMaxlagSeconds: 2 } ); - clock.tickAsync( 2000 ); + await clock.tickAsync( 2000 ); const response = await promise; expect( response ).to.eql( { response: true } ); } ); @@ -763,7 +773,7 @@ describe( 'Session', () => { { response: { response: true } }, ] ); const promise = session.request( {}, { retryAfterReadonlySeconds: 10 } ); - clock.tickAsync( 10000 ); + await clock.tickAsync( 10000 ); const response = await promise; expect( response ).to.eql( { response: true } ); } );