Skip to content

Commit

Permalink
update config with to-do just so that it never fail
Browse files Browse the repository at this point in the history
  • Loading branch information
pixincreate committed Jan 24, 2025
1 parent a932d2e commit 15484dd
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 17 deletions.
40 changes: 25 additions & 15 deletions cypress-tests/cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,25 @@ export default defineConfig({
},
});
on("after:spec", (spec, results) => {
if (results && results.video) {
// Do we have failures for any retry attempts?
const failures = results.tests.some((test) =>
// Clean up resources after each spec
if (
results &&
results.video &&
!results.tests.some((test) =>
test.attempts.some((attempt) => attempt.state === "failed")
);
if (!failures) {
// delete the video if the spec passed and no tests retried
fs.unlinkSync(results.video);
}
)
) {
// Delete video for passed specs
fs.unlinkSync(results.video);
}
});
return config;
},
experimentalRunAllSpecs: true,

specPattern: "cypress/e2e/**/*.cy.{js,jsx,ts,tsx}",
supportFile: "cypress/support/e2e.js",

reporter: "cypress-mochawesome-reporter",
reporterOptions: {
reportDir: `cypress/reports/${connectorId}`,
Expand All @@ -55,12 +59,18 @@ export default defineConfig({
inlineAssets: true,
saveJson: true,
},
defaultCommandTimeout: 10000,
pageLoadTimeout: 20000,
responseTimeout: 30000,
screenshotsFolder: screenshotsFolderName,
video: true,
videoCompression: 32,
chromeWebSecurity: false,
// TODO: Plan migration strategy for v15 when injectDocumentDomain is removed
// Options:
// 1. Restructure tests to avoid cross-subdomain testing
// 2. Use alternative domain handling approaches
// 3. Keep using v14 if cross-subdomain testing is critical
injectDocumentDomain: true,
},
chromeWebSecurity: false,
defaultCommandTimeout: 10000,
pageLoadTimeout: 20000,
responseTimeout: 30000,
screenshotsFolder: screenshotsFolderName,
video: true,
videoCompression: 32,
});
12 changes: 11 additions & 1 deletion cypress-tests/cypress/support/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,22 @@
// Import commands.js using ES2015 syntax:
import "cypress-mochawesome-reporter/register";
import "./commands";
import "./redirectionHandler";

Cypress.on("window:before:load", (win) => {
// Add security headers
win.headers = {
"Content-Security-Policy": "default-src 'self'",
"X-Content-Type-Options": "nosniff",
"X-Frame-Options": "DENY",
};
});

// Add error handling for dynamic imports
Cypress.on("uncaught:exception", (err, runnable) => {
// Log the error details
// eslint-disable-next-line no-console
console.log(
console.error(
`Error: ${err.message}\nError occurred in: ${runnable.title}\nStack trace: ${err.stack}`
);

Expand Down
3 changes: 2 additions & 1 deletion cypress-tests/cypress/support/redirectionHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -526,9 +526,10 @@ function verifyReturnUrl(redirection_url, expected_url, forward_flow) {
Cypress.on("uncaught:exception", (err, runnable) => {
// Log the error details
// eslint-disable-next-line no-console
console.log(
console.error(
`Error: ${err.message}\nError occurred in: ${runnable.title}\nStack trace: ${err.stack}`
);

// Return false to prevent the error from failing the test
return false;
});
Expand Down

0 comments on commit 15484dd

Please sign in to comment.