[IMP] tests: add tests for custom jest matchers#8841
Open
hokolomopo wants to merge 2 commits into
Open
Conversation
Collaborator
We re-defined the standard `toBeCloseTo` matcher in order to use it
in `expect(...).toMatchObject({ x: expect.toBeCloseTo(...)})`. But
we can just use `expect.closeTo(1000)` instead.
Task: 6272392
We define custom jest matcher (eg. `expect(color).toBeSameColorAs(otherColor)`) but never actually test that those work correctly. They, in fact, did not. - most of the matchers had wrong error message when used with `expect().not` - `expect().not.toExport` didn't work correctly (but was never used) Most of the error message tests are written with snapshots, because we use jest helpers to color/prettify the output, and testing those is a pain. Task: 6272392
d67eea2 to
98328ee
Compare
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.

Description:
[IMP] tests: add tests for custom jest matchers
We define custom jest matcher (eg.
expect(color).toBeSameColorAs(otherColor))but never actually test that those work correctly. They, in fact, did not.
expect().notexpect().not.toExportdidn't work correctly (but was never used)Most of the error message tests are written with snapshots, because
we use jest helpers to color/prettify the output, and testing those
is a pain.
[REF] tests: remove custom
toBeCloseTomatcherWe re-defined the standard
toBeCloseTomatcher in order to use itin
expect(...).toMatchObject({ x: expect.toBeCloseTo(...)}). Butwe can just use
expect.closeTo(1000)instead.Task: 6272392
review checklist