strapi/test/helpers/waitRestart.js
Alexandre Bodin 07e7cfc0bd Make lint stricter and fix the errors
Signed-off-by: Alexandre Bodin <bodin.alex@gmail.com>
2020-11-02 19:41:42 +01:00

26 lines
665 B
JavaScript

'use strict';
const request = require('request-promise-native');
module.exports = function(initTime = 200) {
const ping = async () => {
return new Promise((resolve, reject) => {
// ping _health
request({
url: 'http://localhost:1337/_health',
method: 'HEAD',
mode: 'no-cors',
json: true,
headers: {
'Content-Type': 'application/json',
'Keep-Alive': false,
},
}).then(resolve, reject);
}).catch(() => {
return new Promise(resolve => setTimeout(resolve, 200)).then(ping);
});
};
return new Promise(resolve => setTimeout(resolve, initTime)).then(ping);
};