Closed ammut closed 2 days ago
Can you provide a quick example and also your current workaround? https://github.com/dubzzz/fast-check/issues/660#issuecomment-2435642063 Your suggestion sounds reasonable, but it would be nice to have a concrete code to see the issue better.
Of course, sorry about that!
But it would be way less of a hassle if I had this output:
Thanks for the code. I moved it to stackblitz https://stackblitz.com/edit/sb1-n2fgtd?file=src%2FmyFunction.test.ts I'm not sure how you're doing the 2nd one. Is it something configurable or are you patching fast-check?
Yes, I have managed to patch fast-check to achieve that result, but haven't tried patching vitest yet.
Hmm, I just remembered fast-check author did some improvement related to this:
It looks like this is supposed to work now, but maybe it's a regression on Vitest or fast-check.
Oh, I just noticed my repro is using old Vitest 1.3.1 (also it was private, sorry) :facepalm: Here is a repro with latest Vitest and it looks working now https://stackblitz.com/edit/sb1-ecvswh?file=src%2FmyFunction.test.ts @ammut Can you check which Vitest you use?
Hello @ammut. Please provide a minimal reproduction using a GitHub repository or StackBlitz (you can also use examples). Issues marked with needs reproduction
will be closed if they have no activity within 3 days.
Oof, that would be embarrassing... But also pretty cool! I'll check as soon as I'm back at work
Jep, that was it. Looks like a lot of stuff happened in the last few months. Thanks a lot of taking your time!
Clear and concise description of the problem
I'm working with fast-check, a Property-Based-Testing library that generates random input to your functions and tries to find inputs for which the supposed assertions about your code don't hold.
I like combining it with vitest's
deepEqual
assertions. However, fast-check needs to wrap the error thrown bydeepEqual
so it can provide information about which input specifically caused my assertions to break. To help with debugging, it includes the error thrown bydeepEqual
ascause
, which is already being displayed by vitest. However, the error message can look like this:The error thrown by
fast-check
doesn't haveactual
andexpected
, theAssertionError
however definitely does.Suggested solution
When a test fails and the error does not have the
actual
andexpected
properties, vitest should try to trace back theerror.cause
chain (if there is one) to see if one of the root cause errors does have theactual
andexpected
properties, and then use those to print those sweet, sweet diffs.Alternative
I also suggested in fast-check to just copy over the
actual
andexpected
properties to the wrapping error, but that would fix it only for fast-check.Additional context
No response
Validations