-
-
Notifications
You must be signed in to change notification settings - Fork 181
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
✨ Attach the original Error
as a cause of thrown one
#2965
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 6e21c90:
|
Codecov Report
@@ Coverage Diff @@
## main #2965 +/- ##
==========================================
- Coverage 95.58% 95.48% -0.10%
==========================================
Files 212 212
Lines 5815 5828 +13
Branches 1072 1075 +3
==========================================
+ Hits 5558 5565 +7
- Misses 257 263 +6
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
This comment was marked as outdated.
This comment was marked as outdated.
Waiting the end of my work on 'better handling of poisoning' before reliving this PR. In order not to break the existing users, the error with cause will be provided as an opt-in option. Helpers around test runners (not any for vitest yet but will come) will probably enforce it according to how well the test runner handle them. |
This will be nice so I can stop using: fc.context(), (input, ctx) => { ctx.log(`input: ${input}, output: ${functionUnderTest(input)}`); } in my property tests |
Interested to now why you need this pattern? By the way, you can override the default error reporter if needed |
I have a pretty similar goal to #660 i think - I want to see the expected vs actual values on |
please deploy |
Give a try to 5307918 with: yarn add https://632a07884ff4a50bae9af377--dazzling-goodall-4f0e38.netlify.app/fast-check.tgz
npm i https://632a07884ff4a50bae9af377--dazzling-goodall-4f0e38.netlify.app/fast-check.tgz Or have a look to the generated documentation. |
With the new flag against vitest: Code snippetimport { test, expect } from "vitest";
import fc from "fast-check";
fc.configureGlobal({ errorWithCause: true });
test("error cause", () => {
fc.assert(
fc.property(fc.integer(), (n) => {
return n <= 10;
})
);
});
test("error cause (expect)", () => {
fc.assert(
fc.property(fc.integer(), (n) => {
expect(n).toBeLessThanOrEqual(10);
})
);
}); With the flag against node: Code snippet 1const fc = require("fast-check");
fc.configureGlobal({ errorWithCause: true });
fc.assert(
fc.property(fc.integer(), (n) => {
return n <= 10;
})
); Code snippet 2const assert = require("assert");
const fc = require("fast-check");
fc.configureGlobal({ errorWithCause: true });
fc.assert(
fc.property(fc.integer(), (n) => {
assert(n <= 10);
})
); |
Category:
Potential impacts: