Skip to content
Snippets Groups Projects
Unverified Commit 0bfcae26 authored by Nemanja Glumac's avatar Nemanja Glumac Committed by GitHub
Browse files

[E2E] Use NodeJS `http` module for Cypress backend (#25952)

parent c6471376
No related branches found
No related tags found
No related merge requests found
......@@ -5,7 +5,7 @@ const { spawn } = require("child_process");
const os = require("os");
const path = require("path");
const fetch = require("isomorphic-fetch");
const http = require("http");
const CypressBackend = {
createServer(port = 4000) {
......@@ -107,9 +107,30 @@ const CypressBackend = {
}
async function isReady(host) {
// This is needed until we can use NodeJS native `fetch`.
function request(url) {
return new Promise((resolve, reject) => {
const req = http.get(url, res => {
let body = "";
res.on("data", chunk => {
body += chunk;
});
res.on("end", () => {
resolve(JSON.parse(body));
});
});
req.on("error", e => {
reject(e);
});
});
}
try {
const { status } = await fetch(`${host}/api/health`);
if (status === 200) {
const { status } = await request(`${host}/api/health`);
if (status === "ok") {
return true;
}
} catch (e) {}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment