Is there a way to implement warnings instead of failures for non-critical assertions in Playwright TypeScript tests?
Currently, while working on Playwright tests using TypeScript, I am searching for a solution to handle assertions that would issue warnings without halting the tests. Here is the context:
Assertion Context: I aim to validate CSS, DOM attributes, and other non-critical elements during my testing.
Current Issue: Traditional hard or soft assertions result in immediate test failure (hard) or upon completion (soft).
Desired Behavior: Instead of terminating the tests, I prefer these assertions to generate warnings. This means that even if an assertion fails, the test should continue running, with the status displayed as green/yellow or with a warning indicator, not red.
Technology Stack: My test automation setup involves Playwright with TypeScript.
Example Use Case: For instance, when validating a CSS property or a DOM attribute value, I would like to raise a warning message if the expected and actual values do not match, but I do not want the test to fail.
I have explored soft assertions and custom error handling options, but a straightforward solution has eluded me so far.
This capability is vital as I run 1500 tests on a CI/CD pipeline. Failures due to flaky CSS or attribute values can lead to chaos. Rather than removing these tests entirely, I seek to retain them with minimal assertions.
If you could provide any guidance or code snippets using Playwright and TypeScript, it would be greatly appreciated!
Is achieving this functionality feasible?