Skip to content

Commit

Permalink
fixes to cypress cloud and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelangarano committed Sep 14, 2023
1 parent 949701d commit 47940f2
Show file tree
Hide file tree
Showing 11 changed files with 1,953 additions and 350 deletions.
41 changes: 21 additions & 20 deletions e2e/cypress-13-demo/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,26 @@ import { defineConfig } from "cypress";
import currents from "cypress-cloud/plugin";

module.exports = defineConfig({
e2e: {
baseUrl: "https://todomvc.com/examples/vanillajs",
supportFile: "cypress/support/e2e.ts",
specPattern: "cypress/*/**/*.spec.js",
setupNodeEvents(on, config) {
require("@cypress/grep/src/plugin")(config);
// require("cypress-terminal-report/src/installLogsPrinter")(on);
return currents(on, config);
},
},
video: true,
e2e: {
baseUrl: "https://todomvc.com/examples/vanillajs",
supportFile: "cypress/support/e2e.ts",
specPattern: "cypress/*/**/*.spec.js",
setupNodeEvents(on, config) {
require("@cypress/grep/src/plugin")(config);
// require("cypress-terminal-report/src/installLogsPrinter")(on);
return currents(on, config);
},
},

component: {
specPattern: ["pages/__tests__/*.spec.tsx"],
setupNodeEvents(on, config) {
return currents(on, config);
},
devServer: {
framework: "next",
bundler: "webpack",
},
},
component: {
specPattern: ["pages/__tests__/*.spec.tsx"],
setupNodeEvents(on, config) {
return currents(on, config);
},
devServer: {
framework: "next",
bundler: "webpack",
},
},
});

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

Large diffs are not rendered by default.

83 changes: 66 additions & 17 deletions e2e/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ export const avoidablePropertiesCy13: AvoidableProperty[] = [
property: "config.resolved.browsers.value[1].version",
mustHave: true,
},
{
property: "spec.name",
mustHave: false,
},
];

export const avoidableApiPropertiesCy13: AvoidableProperty[] = [
Expand Down Expand Up @@ -275,51 +279,72 @@ export const avoidedButNeedePropertiesCy13: AvoidableProperty[] = [
property: "config.resolved.videoUploadOnPasses",
mustHave: false,
},
// {
// property: /runs\[\d+\]\.video/,
// mustHave: true,
// isRegex: true,
// },
{
property: /runs\[\d+\]\.video/,
mustHave: true,
property: /runs\[\d+\]\.hooks/,
mustHave: false,
isRegex: true,
},
// {
// property: /runs\[\d+\]\.tests\[\d+\]\.body/,
// mustHave: true,
// isRegex: true,
// },
// {
// property:
// /runs\[\d+\]\.tests\[\d+\]\.attempts\[\d+\]\.timings\.after each\[1\]/,
// mustHave: true,
// isRegex: true,
// },
// {
// property:
// /runs\[\d+\]\.tests\[\d+\]\.attempts\[\d+\]\.timings\.after all/,
// mustHave: true,
// isRegex: true,
// },
{
property: /runs\[\d+\]\.tests\[\d+\]\.attempts\[\d+\]\.timings/,
mustHave: false,
isRegex: true,
},
{
property: /runs\[\d+\]\.hooks/,
property: "config.video",
mustHave: true,
isRegex: true,
},
{
property: /runs\[\d+\]\.tests\[\d+\]\.body/,
property: "config.videoCompression",
mustHave: true,
isRegex: true,
},
{
property:
/runs\[\d+\]\.tests\[\d+\]\.attempts\[\d+\]\.timings\.after each\[1\]/,
property: "config.videoUploadOnPasses",
mustHave: true,
isRegex: true,
},
{
property:
/runs\[\d+\]\.tests\[\d+\]\.attempts\[\d+\]\.timings\.after all/,
property: "runs[2].tests[0].attempts[0]",
mustHave: true,
isRegex: true,
},
{
property: "config.video",
property: "runs[2].tests[0].testId",
mustHave: true,
},
{
property: "config.videoCompression",
property: "error.codeFrame.absoluteFile",
mustHave: true,
},
{
property: "config.videoUploadOnPasses",
property: "timings",
mustHave: true,
},
{
property: "runs[2].tests[0].attempts[0]",
property: "hooks",
mustHave: true,
},
{
property: "runs[2].tests[0].testId",
property: "config.resolved.video.from",
mustHave: true,
},
];
Expand Down Expand Up @@ -487,12 +512,36 @@ export function testEachResults(
result.path
} does not exist and it should. ${result.note ?? ""}`
).not.to.equal("Does not exist");
expect(
result.valueB,
`The values at ${
result.path
} does not exist and it should. ${result.note ?? ""}`
).not.to.equal(undefined);
expect(
result.valueB,
`The values at ${
result.path
} does not exist and it should. ${result.note ?? ""}`
).not.to.equal(null);
expect(
result.valueB,
`The values at ${
result.path
} does not exist and it should. ${result.note ?? ""}`
).not.to.equal("");
expect(
result.valueB,
`The values at ${
result.path
} does not exist and it should. ${result.note ?? ""}`
).not.to.equal("undefined");
expect(
result.valueB,
`The values at ${
result.path
} does not exist and it should. ${result.note ?? ""}`
).not.to.equal("null");
return;
}
}
Expand Down
116 changes: 59 additions & 57 deletions packages/cypress-cloud/lib/results/captureHooks.ts
Original file line number Diff line number Diff line change
@@ -1,70 +1,72 @@
import { ExecutionState } from "../state";
import { generateRandomString } from "../utils";

export function handleScreenshotEvent(
screenshot: Cypress.ScreenshotDetails,
executionState: ExecutionState
screenshot: Cypress.ScreenshotDetails,
executionState: ExecutionState
) {
const testId = executionState.getCurrentTestID();
const screenshotData = {
...screenshot,
testId,
height: screenshot.dimensions.height,
width: screenshot.dimensions.width,
};
executionState.setScreenshotsData(screenshotData);
const testId = executionState.getCurrentTestID();
const screenshotData = {
...screenshot,
testId,
height: screenshot.dimensions.height,
width: screenshot.dimensions.width,
screenshotId: generateRandomString(6),
};
executionState.setScreenshotsData(screenshotData);
}

export function handleTestBefore(
testAttempt: string,
executionState: ExecutionState
testAttempt: string,
executionState: ExecutionState
) {
executionState.setCurrentTestID(JSON.parse(testAttempt).id);
executionState.setCurrentTestID(JSON.parse(testAttempt).id);
}

export function handleTestAfter(
testAttempt: string,
executionState: ExecutionState
testAttempt: string,
executionState: ExecutionState
) {
const test = JSON.parse(testAttempt);
const {
title,
body,
retries,
_currentRetry,
pending,
type,
invocationDetails,
id,
hooks,
order,
wallClockStartedAt,
timings,
_events,
_eventsCount,
duration,
err,
state,
fullTitle,
} = test;
const attempt = {
title,
fullTitle,
body,
retries,
_currentRetry,
pending,
type,
invocationDetails,
id,
hooks,
order,
wallClockStartedAt,
timings,
_events,
_eventsCount,
duration,
err,
state,
};
executionState.setAttemptsData(attempt);
const test = JSON.parse(testAttempt);
const {
title,
body,
retries,
_currentRetry,
pending,
type,
invocationDetails,
id,
hooks,
order,
wallClockStartedAt,
timings,
_events,
_eventsCount,
duration,
err,
state,
fullTitle,
} = test;
const attempt = {
title,
fullTitle,
body,
retries,
_currentRetry,
pending,
type,
invocationDetails,
id,
hooks,
order,
wallClockStartedAt,
timings,
_events,
_eventsCount,
duration,
err,
state,
};
executionState.setAttemptsData(attempt);
}
Loading

0 comments on commit 47940f2

Please sign in to comment.