-
-
Notifications
You must be signed in to change notification settings - Fork 182
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
Jest: expected/received diff appears twice #3634
Comments
Hey, It's a partly known issue. If you are using the latest version of Jest, can you give a try to the flag It can easily be done by running the following code either on top of your file or in the setups file of Jest if you do use one: fc.configureGlobal({ errorWithCause: true }); I'll probably add this setup as the default one in |
This is what I tried: const fc = require("fast-check");
+fc.configureGlobal({ errorWithCause: true });
it("works", () => {
fc.assert(
fc.property(fc.string(), (a) => {
expect("foo").toEqual("bar");
})
);
});
Below is the result. Unfortunately it looks like the diff ("expected" and "received") doesn't appear at all now. 🤔 $ jest
FAIL ./test.js
✕ works (6 ms)
● works
Property failed after 1 tests
{ seed: -380473213, path: "0:0", endOnFailure: true }
Counterexample: [""]
Shrunk 1 time(s)
Hint: Enable verbose mode in order to have the list of all failing values encountered during the run
3 |
4 | it("works", () => {
> 5 | fc.assert(
| ^
6 | fc.property(fc.string(), (a) => {
7 | expect("foo").toEqual("bar");
8 | })
at buildError (node_modules/fast-check/lib/check/runner/utils/RunDetailsFormatter.js:134:19)
at throwIfFailed (node_modules/fast-check/lib/check/runner/utils/RunDetailsFormatter.js:143:11)
at reportRunDetails (node_modules/fast-check/lib/check/runner/utils/RunDetailsFormatter.js:156:16)
at Object.assert (node_modules/fast-check/lib/check/runner/Runner.js:81:52)
at Object.assert (test.js:5:6)
Test Suites: 1 failed, 1 total
Tests: 1 failed, 1 total
Snapshots: 0 total
Time: 0.225 s, estimated 1 s
Ran all test suites. |
For the Error with cause, issue seems to be coming from Jest. I'm currently working on a PR to make it fully supported. For the other issue, I'll attempt a fix on Jest side too. I'll let you know as soon as something gets merged on Jest side. |
A PR attempting to make Error with cause working has been opened on Jest's side, see jestjs/jest#13935 |
Regarding the remaining issue at the origin the bug report, I mean: Got error: Error: expect(received).toEqual(expected) // deep equality
Expected: "bar"
Received: "foo"
Stack trace: Error: expect(received).toEqual(expected) // deep equality
Expected: "bar"
Received: "foo" Actually the bug is fully on fast-check's side 🤔 I'll have to check how I can deal with it properly. It seems that most of the time stack includes the message itself. So printing both implies duplicates. |
While the change could have been considered as a bug fix, I prefer including it as a fresh new feature to avoid risks of breaking people relying on this bug. Fixes #3634
* ✨ Stop repeating the error twice in reports While the change could have been considered as a bug fix, I prefer including it as a fresh new feature to avoid risks of breaking people relying on this bug. Fixes #3634 * Drop Error: from report * versions * unfify stacks cross os * safer poisoned * format * Update packages/fast-check/test/e2e/NoRegressionStack.spec.ts * Update packages/fast-check/test/e2e/__snapshots__/NoRegressionStack.spec.ts.snap * Update packages/fast-check/test/e2e/__snapshots__/NoRegressionStack.spec.ts.snap * Update packages/fast-check/test/e2e/__snapshots__/NoRegressionStack.spec.ts.snap * Update packages/fast-check/test/e2e/__snapshots__/NoRegressionStack.spec.ts.snap * Update packages/fast-check/test/e2e/__snapshots__/NoRegressionStack.spec.ts.snap * fix no reg * fix unit
Fix for non-cause mode will be included in version 3.7.0 of fast-check |
🐛 Bug Report
To Reproduce
In a new directory:
yarn add jest fast-check
test.js
jest
Result:
Observe how the expected/received diff appears twice:
Expected behavior
The expected/received diff should only appear once.
If you have one, please provide a minimal repository reproducing the issue on GitHub.
Your environment
*Only for TypeScript's users
This issue seems similar to #399, although not exactly the same.
The text was updated successfully, but these errors were encountered: