-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
[Feature]: Add expect.soft for setup and soft assertions #13205
Comments
I like the idea! Main issue is that |
@SimenB Do you have a rough idea of what binding expect to single tests would entail, is there some sketch of the required work I can read up on? |
It is not to advertise, but to help, but I think this covers the need: https://github.com/alfonso-presa/soft-assert Let me know if it helps (or not :-) ) |
the expect should have the similar functionality than soft-assert. |
🚀 Feature Proposal
A new method
soft
on theexpect
object giving test authors fine grained control over the control flow of their test case. An assertion decorated with.soft
continues execution of a test case after assertion's failure to gather more data e.g. via remaining assertions in the case.Motivation
This provides new tools to test authors striving to write more expressive and easier to debug tests.
Example
I often encounter test case with intermediary assertions designed to ensure a precondition relevant to the final assertion is met.
This works but is sub-optimal in so far as in the case of a precondition failure useful debugging information is lost as execution stops after the first failed assertion:
Consider the same case with a hypothetical
.soft
assertion that continues execution but fails the test case if any (soft or not) assertion is not metPitch
This will lead to better test suites which I take is jest's mission. 🚀
Prior art
Playwright implements this: https://playwright.dev/docs/test-assertions#soft-assertions
The text was updated successfully, but these errors were encountered: