Skip to content

Commit

Permalink
fix for cypress 13 ccy 1.10
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelangarano committed Sep 9, 2023
1 parent 2c08548 commit bda5ae1
Show file tree
Hide file tree
Showing 14 changed files with 742 additions and 609 deletions.
91 changes: 52 additions & 39 deletions e2e/cypress-12-demo/scripts/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,61 @@ import { run } from "cypress-cloud";
import fs from "fs";

(async function runTests() {
const projectId = process.env.CURRENTS_PROJECT_ID || "2cI1I5";
const recordKey = process.env.CURRENTS_RECORD_KEY || "YakSabgBLb7D40nZ";
const apiKey = process.env.CURRENTS_API_KEY || "YpYIAerb1rWuOFrvf7ciK8Za8koKgrtRfoDPboQUOjScnBv91m4qAXSDb8Rb57m9";
const apiUrl = "https://api.currents.dev/v1/runs/"
const projectId = process.env.CURRENTS_PROJECT_ID || "2cI1I5";
const recordKey = process.env.CURRENTS_RECORD_KEY || "YakSabgBLb7D40nZ";
const apiKey =
process.env.CURRENTS_API_KEY ||
"YpYIAerb1rWuOFrvf7ciK8Za8koKgrtRfoDPboQUOjScnBv91m4qAXSDb8Rb57m9";
const apiUrl = "https://api.currents.dev/v1/runs/";

const ciBuildId = `run-api-smoke-${new Date().toISOString()}`;
const result: any = await run({
ciBuildId,
projectId,
recordKey,
batchSize: 4
});
assert(result !== undefined);
const ciBuildId = `run-api-smoke-${new Date().toISOString()}`;
const result: any = await run({
ciBuildId,
projectId,
recordKey,
batchSize: 4,
});
assert(result !== undefined);

const headers = new Headers({
'Authorization': `Bearer ${apiKey}`,
});
const headers = new Headers({
Authorization: `Bearer ${apiKey}`,
});

fs.writeFile('data-references/ccy-1.10-cypress-12/cypress-cloud-output-reference.json', JSON.stringify(result), (err) => {
if (err) throw err;
console.log('file saved');
});
fs.writeFile(
"data-references/ccy-1.10-cypress-12/cypress-cloud-output-reference.json",
JSON.stringify(result),
(err) => {
if (err) throw err;
console.log("file saved");
}
);

const runUrl = result.runUrl;
const runUrl = result.runUrl;

fetch(`${apiUrl}${runUrl.split("run/")[1]}`, {
method: "GET",
headers
})
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
return response.json();
})
.then(data => {
fs.writeFile('data-references/ccy-1.10-cypress-12/currents-api-output-reference.json', JSON.stringify(data), (err) => {
if (err) throw err;
console.log('file saved');
});
})
.catch(error => {
console.error('There was an error in fetch request:', error.message);
});
await fetch(`${apiUrl}${runUrl.split("run/")[1]}`, {
method: "GET",
headers,
})
.then((response) => {
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
return response.json();
})
.then((data) => {
fs.writeFile(
"data-references/ccy-1.10-cypress-12/currents-api-output-reference.json",
JSON.stringify(data),
(err) => {
if (err) throw err;
console.log("file saved");
}
);
})
.catch((error) => {
console.error(
"There was an error in fetch request:",
error.message
);
});
})();
Loading

0 comments on commit bda5ae1

Please sign in to comment.