From 08f84475e7326804c815e1578b0c2e98a5008890 Mon Sep 17 00:00:00 2001 From: Daniel Lockyer Date: Fri, 10 Mar 2023 11:18:42 +0100 Subject: [PATCH] Removed `sleep` lib from test utils - this is generally an anti-pattern in tests and leads to flaky behaviour when tests are ran on different machines/loads - this is currently unused so it is an easy removal --- ghost/core/test/e2e-api/admin/images.test.js | 1 - ghost/core/test/utils/e2e-framework.js | 1 - ghost/core/test/utils/sleep.js | 15 --------------- 3 files changed, 17 deletions(-) delete mode 100644 ghost/core/test/utils/sleep.js diff --git a/ghost/core/test/e2e-api/admin/images.test.js b/ghost/core/test/e2e-api/admin/images.test.js index 1448d06ec4..b4972c45c7 100644 --- a/ghost/core/test/e2e-api/admin/images.test.js +++ b/ghost/core/test/e2e-api/admin/images.test.js @@ -8,7 +8,6 @@ const urlUtils = require('../../../core/shared/url-utils'); const imageTransform = require('@tryghost/image-transform'); const sinon = require('sinon'); const storage = require('../../../core/server/adapters/storage'); -const sleep = require('../../utils/sleep'); const {anyErrorId} = matchers; const {imageSize} = require('../../../core/server/lib/image'); const configUtils = require('../../utils/configUtils'); diff --git a/ghost/core/test/utils/e2e-framework.js b/ghost/core/test/utils/e2e-framework.js index 334263bfca..4febded4f0 100644 --- a/ghost/core/test/utils/e2e-framework.js +++ b/ghost/core/test/utils/e2e-framework.js @@ -480,6 +480,5 @@ module.exports = { configUtils: require('./configUtils'), dbUtils: require('./db-utils'), urlUtils: require('./urlUtils'), - sleep: require('./sleep'), resetRateLimits }; diff --git a/ghost/core/test/utils/sleep.js b/ghost/core/test/utils/sleep.js deleted file mode 100644 index 70767e0d07..0000000000 --- a/ghost/core/test/utils/sleep.js +++ /dev/null @@ -1,15 +0,0 @@ -/** - * Adds artificial "sleep" time that can be awaited - * In most cases where this module is used we are awaiting - * for the async event processing to trigger/finish - * - * Can probably be substituted by timerPromises in the future - * ref.: https://nodejs.org/dist/latest-v18.x/docs/api/timers.html#timerspromisessettimeoutdelay-value-options - * @param {number} ms - * @returns {Promise} - */ -module.exports = ms => ( - new Promise((resolve) => { - setTimeout(resolve, ms); - }) -);