From ac0dc10bd50a9e0c583ac05575f03722a861deea Mon Sep 17 00:00:00 2001 From: Ingvar Stepanyan Date: Tue, 15 Nov 2022 08:58:09 +0000 Subject: [PATCH] Tests: convert mocha hooks (#3450) --- .mocharc.jsonc | 1 + test/{unit => }/beforeEach.js | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) rename test/{unit => }/beforeEach.js (62%) diff --git a/.mocharc.jsonc b/.mocharc.jsonc index 4cde66cb..06df4ac9 100644 --- a/.mocharc.jsonc +++ b/.mocharc.jsonc @@ -2,5 +2,6 @@ "parallel": true, "slow": 1000, "timeout": 30000, + "require": "./test/beforeEach.js", "spec": "./test/unit/*.js" } diff --git a/test/unit/beforeEach.js b/test/beforeEach.js similarity index 62% rename from test/unit/beforeEach.js rename to test/beforeEach.js index 9d055a0b..42830d44 100644 --- a/test/unit/beforeEach.js +++ b/test/beforeEach.js @@ -1,7 +1,7 @@ 'use strict'; const detectLibc = require('detect-libc'); -const sharp = require('../../'); +const sharp = require('../'); const libcFamily = detectLibc.familySync(); const usingCache = !(process.env.G_DEBUG || libcFamily === detectLibc.MUSL); @@ -9,14 +9,16 @@ const usingSimd = !(process.env.G_DEBUG || process.env.VIPS_NOVECTOR); const concurrency = process.env.VIPS_CONCURRENCY || (libcFamily === detectLibc.MUSL || process.arch === 'arm' ? 1 : undefined); -beforeEach(function () { - sharp.cache(usingCache); - sharp.simd(usingSimd); - sharp.concurrency(concurrency); -}); +exports.mochaHooks = { + beforeEach () { + sharp.cache(usingCache); + sharp.simd(usingSimd); + sharp.concurrency(concurrency); + }, -afterEach(function () { - if (global.gc) { - global.gc(); + afterEach () { + if (global.gc) { + global.gc(); + } } -}); +};