-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Custom timeouts are ignored on retry attempts. #8336
Comments
I'm not able to recreate this behavior - clicking the retry / editing the specfile maintains the original You may want to make sure that your file changes are being seen - that your app is not using service workers that prevent this. #702 Otherwise, we will need a fully reproducible example to look into this - maybe there's something in your support/plugins/config that is affecting this. |
So it turns out that it's the following code that I'm adding as a support module to provide soft assertions that is breaking it! let isSoftAssertion = false;
let errors = [];
chai.softExpect = function ( ...args ) {
isSoftAssertion = true;
return chai.expect(...args);
},
chai.softAssert = function ( ...args ) {
isSoftAssertion = true;
return chai.assert(...args);
}
const origAssert = chai.Assertion.prototype.assert;
chai.Assertion.prototype.assert = function (...args) {
if ( isSoftAssertion ) {
try {
origAssert.call(this, ...args)
} catch ( error ) {
errors.push(error);
}
isSoftAssertion = false;
} else {
origAssert.call(this, ...args)
}
};
// monkey-patch `Cypress.log` so that the last `cy.then()` isn't logged to command log
const origLog = Cypress.log;
Cypress.log = function ( data ) {
if ( data && data.error && /soft assertions/i.test(data.error.message) ) {
data.error.message = '\n\n\t' + data.error.message + '\n\n';
throw data.error;
}
return origLog.call(Cypress, ...arguments);
};
// monkey-patch `it` callback so we insert `cy.then()` as a last command
// to each test case where we'll assert if there are any soft assertion errors
function itCallback ( func ) {
func();
cy.then(() => {
if ( errors.length ) {
const _ = Cypress._;
let msg = '';
if ( Cypress.browser.isHeaded ) {
msg = 'Failed soft assertions... check log above ↑';
} else {
_.each( errors, error => {
msg += '\n' + error;
});
msg = msg.replace(/^/gm, '\t');
}
throw new Error(msg);
}
});
}
const origIt = window.it;
window.it = (title, func) => {
origIt(title, func && (() => itCallback(func)));
};
window.it.only = (title, func) => {
origIt.only(title, func && (() => itCallback(func)));
};
window.it.skip = (title, func) => {
origIt.skip(title, func);
};
beforeEach(() => {
errors = [];
});
afterEach(() => {
errors = [];
isSoftAssertion = false;
}); Can't say that I understand why this breaks it... but could there be something in how Cypress handles |
I am able to reproduce this in Cypress version 4.8.0-4.12.1 - this was a regression introduced in 4.8.0, however I am unable to reproduce this in 5.0.0. Closing as resolved. Please update to our latest version to get this bug fix. |
Finally got round to upgrading to 5 and verifying this fixed the issue. Many thanks @jennifer-shehane ! |
Current behaviour:
Given the following sample spec:
When you first launch this spec file from the runner, the 15s timeout elapses before the test fails. If you then click retry (or edit the spec file, triggering an automatic retry) the test fails after just 3-4s
Desired behaviour:
The specified custom timeout should be respected on retry.
Test code to reproduce
Please see above.
Versions
Cypress 4.10-4.12, CentOS8, and Chrome 83
The text was updated successfully, but these errors were encountered: