diff --git a/package.json b/package.json index beae8452..d5be6711 100644 --- a/package.json +++ b/package.json @@ -179,7 +179,7 @@ "icc": "^3.0.0", "jsdoc-to-markdown": "^9.1.1", "license-checker": "^25.0.1", - "mocha": "^11.2.2", + "mocha": "^11.4.0", "node-addon-api": "^8.3.1", "nyc": "^17.1.0", "prebuild": "^13.0.1", diff --git a/test/unit/util.js b/test/unit/util.js index 9d5b9c62..ecec8a06 100644 --- a/test/unit/util.js +++ b/test/unit/util.js @@ -10,18 +10,20 @@ const sharp = require('../../'); describe('Utilities', function () { describe('Cache', function () { it('Can be disabled', function (done) { - queueMicrotask(() => { - sharp.cache(false); + const check = setInterval(() => { const cache = sharp.cache(false); - assert.strictEqual(cache.memory.current, 0); - assert.strictEqual(cache.memory.max, 0); - assert.strictEqual(typeof cache.memory.high, 'number'); - assert.strictEqual(cache.files.current, 0); - assert.strictEqual(cache.files.max, 0); - assert.strictEqual(cache.items.current, 0); - assert.strictEqual(cache.items.max, 0); - done(); - }); + const empty = + cache.memory.current + + cache.memory.max + + cache.files.current + + cache.files.max + + cache.items.current + + cache.items.max === 0; + if (empty) { + clearInterval(check); + done(); + } + }, 2000); }); it('Can be enabled with defaults', function () { const cache = sharp.cache(true);