From c9e39960075ef84ba604896ada1c318d000a7bdf Mon Sep 17 00:00:00 2001 From: Lovell Fuller Date: Wed, 13 Dec 2023 13:22:59 +0000 Subject: [PATCH] Tests: attempt to reduce chance of race condition --- test/unit/util.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/test/unit/util.js b/test/unit/util.js index fd881a80d..51ed475e3 100644 --- a/test/unit/util.js +++ b/test/unit/util.js @@ -9,16 +9,19 @@ const sharp = require('../../'); describe('Utilities', function () { describe('Cache', function () { - it('Can be disabled', function () { - sharp.cache(false); - 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); + it('Can be disabled', function (done) { + queueMicrotask(() => { + sharp.cache(false); + 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(); + }); }); it('Can be enabled with defaults', function () { const cache = sharp.cache(true);