add an expectAll feature
🚀 Feature Proposal
As a developper I want my test to be able to fail on multiple expects so that I can debug/test faster (I posted an issue on jest and copy pasted the same issue there based on a comment stating that it may have it's place here.
it's the same description but here it is : https://github.com/facebook/jest/issues/9638)
Example
It would work like the assertAll in Junit5
assertAll("Should` return address of Oracle's headquarter",
() -> assertEquals("Redwood Shores", address.getCity()),
() -> assertEquals("Oracle Parkway", address.getStreet()),
() -> assertEquals("500", address.getNumber())
);
instead of :
expect(true).toBe(false); // test runner report only this line as a failure
expect(true).toBe(false);
I suggest :
expectAll(
() => expect(true).toBe(false), // test runner report this line as a failure
() => expect(true).toBe(false) // test runner report this line as a failure
)
Jest is awesome and with this QOL improvement it would enhance developpers productivity even more
I feel this is a legit feature request for jest !
Not so much for this jest-extended library, which aims to support matchers,
while this is more a core jest assertion bubbling modification request.
Having used this effectively and extensively in Junit5 - assertAll, it is really a better user experience to not have to fix one error at a time and instead! 😄
API REQ: expectAll
Asserts that all supplied executables do not throw an (Assertion) Error.
If any of the supplied executable throws an
AssertionError, all remaining executables should still be executed, and all failures can be aggregated and reported in aMultipleFailuresError.
Else if an executable throws an exception that is not an
AssertionError, execution should halt immediately, and the exception should be re-thrown as is but masked as anUncheckedException.
Bonus:
If Jest does this Error collection more smoother by default for all AssertionErrors within the it block (with some js magic, without an explicitAll assertions),
that would also be Awesome!! 😃
This feature is badly needed :'(