cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
46.38k stars 3.13k forks source link

Soft Assertions in Cypress #29399

Open veerpatil opened 2 months ago

veerpatil commented 2 months ago

What would you like?

Overview: Soft assertions are a critical feature in test automation frameworks, enabling testers to continue executing test cases even after encountering failures, thus providing comprehensive insights into application behavior. As of the current version of Cypress, soft assertions are not natively supported. This feature request proposes the implementation of soft assertions within Cypress to enhance its capabilities and provide a more robust testing experience.

Problem Statement: In traditional test automation frameworks, soft assertions allow testers to validate multiple conditions within a single test case, providing a more comprehensive understanding of application behavior. However, Cypress lacks native support for soft assertions, limiting testers' ability to perform such validations effectively. Presently, encountering a failed assertion in Cypress halts the test execution, preventing subsequent assertions from being evaluated within the same test case.

Proposed Solution: Introducing soft assertions in Cypress would involve enhancing its assertion mechanism to handle failures gracefully without terminating the entire test execution. This enhancement would allow testers to continue evaluating subsequent assertions even after encountering failures, thereby providing a more detailed report of test results. Additionally, incorporating a mechanism to aggregate and report all failed assertions at the end of the test execution would further improve test visibility and debugging.

Why is this needed?

In traditional test automation frameworks, soft assertions allow testers to validate multiple conditions within a single test case, providing a more comprehensive understanding of application behavior. However, Cypress lacks native support for soft assertions, limiting testers' ability to perform such validations effectively. Presently, encountering a failed assertion in Cypress halts the test execution, preventing subsequent assertions from being evaluated within the same test case.

Other

No response

migueldsol commented 2 months ago

Hello @jennifer-shehane . I've been exploring this feature and was wondering if you were open to implementing it into Cypress.

BernardoSousa03 commented 4 weeks ago

Hi @jennifer-shehane! Me and @migueldsol are working on this feature and we have encountered some issues while implementing it. We thought that changing how Cypress handles errors in assertions would be enough to implement soft assertions. Right now we can defer the errors thrown when a soft assertion fails but we lose Cypress ability to retry the assertion before the timeout ends. We would like to use all of Cypress assertion capabilities and i was wondering if you could guide us to handling errors the correct way!