You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// my.test.jsfunctioninvokeWithTry(callback){try{returncallback();}catch(err){returnerr;}}test("fail works in a try/catch",()=>{constresult=invokeWithTry(()=>expect().fail("expected failure"));// Erroneously passesexpect(result).toBeUndefined();// Actually fails here b/c `result` is a `JestAssertionError`});
Bug
package
version: 4.0.1node
version: 18.18.0yarn
version: 1.22.19Relevant code or config
What you did:
I passed a callback containing
expect().fail()
to a function that invokes the callback in atry/catch
block.What happened (please provide anything you think will help):
The failure was not registered since the
catch
intercepted theJestAssertionError
raised by thefail
matcher.Reproduction repository (if possible): https://github.com/thehale/jest-extended-fail-not-working-in-try-catch
The text was updated successfully, but these errors were encountered: