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
This commit is contained in:
Daniel Lockyer 2023-03-10 11:18:42 +01:00 committed by Daniel Lockyer
parent 6f9f83bee8
commit 08f84475e7
3 changed files with 0 additions and 17 deletions

View File

@ -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');

View File

@ -480,6 +480,5 @@ module.exports = {
configUtils: require('./configUtils'),
dbUtils: require('./db-utils'),
urlUtils: require('./urlUtils'),
sleep: require('./sleep'),
resetRateLimits
};

View File

@ -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<void>}
*/
module.exports = ms => (
new Promise((resolve) => {
setTimeout(resolve, ms);
})
);