Skip to content

Commit

Permalink
added throw error test
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelangarano committed Sep 14, 2023
1 parent 47940f2 commit 25ed7c8
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 1,586 deletions.
5 changes: 5 additions & 0 deletions e2e/cypress-13-demo/cypress/e2e/e.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
describe('Should throw an error', () => {
it('Should throw an error', () => {
throw new Error("test error")
});
});

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

1,523 changes: 1 addition & 1,522 deletions e2e/cypress-13-demo/data-references/ccy-1.9.4-cy-12-cycl.json

Large diffs are not rendered by default.

66 changes: 8 additions & 58 deletions e2e/cypress-13-demo/scripts/files.ts
Original file line number Diff line number Diff line change
@@ -1,62 +1,12 @@
import { run } from "cypress-cloud";
import fs from "fs";
import { getApiData, runTests } from "../../utils/utils";

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

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

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

fs.writeFile(
"data-references/ccy-1.9.4-cypress-12/cypress-cloud-output-reference.json",
JSON.stringify(result),
(err) => {
if (err) throw err;
console.log("file saved");
}
(async function runFiles() {
const cypressCloudData = await runTests(
"data-references/ccy-1.9.4-cy-12-cycl.json"
);

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) => {
console.log(data);
fs.writeFile(
"data-references/ccy-1.9.4-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 getApiData(
cypressCloudData.runUrl,
"data-references/ccy-1.9.4-cy-12-crapi.json"
);
})();

Large diffs are not rendered by default.

Large diffs are not rendered by default.

14 changes: 13 additions & 1 deletion e2e/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,18 @@ export const avoidablePropertiesCy13: AvoidableProperty[] = [
property: "spec.name",
mustHave: false,
},
{
property: "runs[3].tests[0].testId",
mustHave: true,
},
{
property: "runs[3].tests[0].body",
mustHave: false,
},
{
property: "runs[3].tests[0].attempts[0]",
mustHave: false,
},
];

export const avoidableApiPropertiesCy13: AvoidableProperty[] = [
Expand Down Expand Up @@ -612,7 +624,7 @@ export async function runTests(filePath: string) {
ciBuildId,
projectId,
recordKey,
batchSize: 4,
batchSize: 5,
});

writeFile(filePath, result);
Expand Down

0 comments on commit 25ed7c8

Please sign in to comment.