Skip to content
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

Remove jest extended #2839

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Remove jest extended #2839

wants to merge 2 commits into from

Conversation

BPScott
Copy link
Member

@BPScott BPScott commented Sep 18, 2024

Description

Remove custom matcher usage from jest-extended and one custom matcher that we define in repo.
This lets us have a simpler test harness.

  • Replace the one usage of jest-extended's toBeObject with a call to expect(BLAH).toMatchObject()
  • Replace the five usages of jest-extended's toBeOneOf with setting up an array of possible items and using expect(possibleResults).toStrictEqual(expect.arrayContaining([VALUE_UNDER_TEST])); which is a little bit upside down but considering it only crops up 5 times I'm not bothered by it.
  • Remove the two assertions that use toBeArrayOfUniqueItems as they both do Object.keys(SOME_OBJECT).toBeArrayOfUniqueItems() and that array is always going to be unique because an object can't have multiple keys with the same value so we're asserting a truism.

We used the matchers from jest-extended in 2 files, and it's possible to
refactor those so it's not needed
@BPScott BPScott requested a review from a team as a code owner September 18, 2024 21:31
It is only ever used to assert that an array returned by Object.keys is
unique, and that's always going to be true as an object can't have two
keys with the same name.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant