Repository navigation
Conversation
The device runner now runs failed test errors through processError from @vitest/utils/error, as Vitest's runner does, and sends the resulting diff in a new optional `diff` field on SerializedError. Merged soft assertion errors keep each failure's diff next to its message, and the Jest reporter prints the diff between the message and the code frame.
|
@mrousavy is attempting to deploy a commit to the Callstack Team on Vercel. A member of the Team first needs to authorize it. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is this?
When an
expectassertion fails, Harness prints the assertion message and the code frame, but no diff. Chai shortens objects in that message, so a failingtoEqualcan look like this:Both sides read the same, and finding the field that differs means logging the values and running the test on the device again. Vitest prints a
- Expected/+ Receiveddiff under the message for the same assertion. Harness uses the same@vitest/expect, so it can print that diff as well. With this change the failure reads:How does it work?
@vitest/expectdoesn't build the diff when an assertion throws. In Vitest, the test runner builds it afterwards by passing the failed test's error toprocessErrorfrom@vitest/utils/error. Harness runs its own runner on the device and never made that call. Soft assertions were the one case with a diff, because@vitest/expectcallsprocessErroron them itself, but Harness dropped those diffs when it merged the soft failures into a single error.The device runner now calls
processErrorwhen a test fails and sends the diff in a new optionaldifffield on the serialized error. When Harness merges several failures into one error, as it does forexpect.soft, each failure's diff goes right after its own message. The Jest reporter printsdiffbetween the message and the code frame.The diff is built on the device because that's where the actual and expected values live.
@vitest/utilswas already in the bundle through@vitest/expect, and the runtime now declares it directly at the same 4.0.16 version.Why is this useful?
You can tell which value is wrong from the CLI output, without adding logs and rerunning on the device. This matters most for
toEqualandtoMatchObjecton larger objects, where chai's message hides the difference. Plugins that read test errors get the diff through the samedifffield.