Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Cypress promise exception handler #9457

Merged
merged 3 commits into from
Sep 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 2 additions & 15 deletions cypress/support/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Cypress.Screenshot.defaults({
});

Cypress.on(`window:before:load`, win => {
cy.stub(win.console, `error`, msg => {
cy.stub(win.console, `error`).callsFake(msg => {
cy.now(`task`, `error`, msg);
throw new Error(msg);
});
Expand All @@ -18,27 +18,14 @@ Cypress.on(`window:before:load`, win => {
// We decided we could not invest any more time in the unexplained error as the test
// successfully functioned with this specific error caught and discarded.
// eslint-disable-next-line consistent-return
Cypress.on('uncaught:exception', (err, runnable, promise) => {
Cypress.on('uncaught:exception', err => {
// returning false here prevents Cypress from failing the test
if (
err.message &&
err.message.includes("Cannot read property 'postMessage' of undefined")
) {
return false;
}

if (promise) {
// When the exception originated from an unhandled promise
// rejection, prevent Cypress from failing the test.

// This feature was added in v7 - https://github.com/bbc/simorgh/pull/9026
// however it's failing our AMP ads tests on feature index pages.

// We should investigate this error when we have more time and
// potentially re-enable unhandled promise rejections failing tests
// Issue - https://github.com/bbc/simorgh/issues/9178
return false;
}
});

require('cypress-terminal-report/src/installLogsCollector')();