Skip to content

Commit

Permalink
Remove dependency on curl in e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorNadj committed Jun 27, 2022
1 parent 36be67e commit 9f55ad1
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 0 additions & 2 deletions packages/devops/ci/e2e.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
FROM cypress/base:14.19.0

RUN apk-add curl

WORKDIR /tupaia

# copy everything
Expand Down
12 changes: 6 additions & 6 deletions packages/e2e/cypress/scripts/testE2e/testE2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import { execSync } from 'child_process';
import {} from 'dotenv/config';
import fs from 'fs';
import { fetch } from 'node-fetch';

import { getArgs, getLoggerInstance } from '@tupaia/utils';
import { E2E_CONFIG_PATH } from '../../constants';
Expand Down Expand Up @@ -68,10 +69,9 @@ const runTestsAgainstUrl = (url, options = {}) => {
});
};

const validateUrl = (description, url) => {
try {
execSync(`curl --output /dev/null --silent --head --fail ${url}`);
} catch (error) {
const validateUrl = async (description, url) => {
const response = await fetch.get(url);
if (!response.ok) {
throw new Error(`No deployment exists for ${description} url '${url}', cancelling e2e tests`);
}
};
Expand All @@ -91,13 +91,13 @@ export const testE2e = async () => {
logger.warn(`Baseline url is empty, stopping e2e tests`);
return;
}
validateUrl('baseline', baselineUrl);
await validateUrl('baseline', baselineUrl);

if (!compareUrl) {
logger.warn(`Compare url is empty, stopping e2e tests`);
return;
}
validateUrl('compare', compareUrl);
await validateUrl('compare', compareUrl);

let baseError;
try {
Expand Down
1 change: 1 addition & 0 deletions packages/e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"markdown-to-jsx": "^6.4.1",
"moment": "^2.21.0",
"moment-timezone": "^0.5.14",
"node-fetch": "^1.7.3",
"npm-run-all": "^4.1.5",
"regenerator-runtime": "^0.13.9"
}
Expand Down
1 change: 1 addition & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5220,6 +5220,7 @@ __metadata:
markdown-to-jsx: ^6.4.1
moment: ^2.21.0
moment-timezone: ^0.5.14
node-fetch: ^1.7.3
npm-run-all: ^4.1.5
regenerator-runtime: ^0.13.9
languageName: unknown
Expand Down

0 comments on commit 9f55ad1

Please sign in to comment.