Skip to content
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.

Remove jest extended #2839

Merged
merged 2 commits into from
Sep 23, 2024
Merged

Remove jest extended #2839

merged 2 commits into from
Sep 23, 2024

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.
@BPScott BPScott merged commit d6fd7d1 into main Sep 23, 2024
5 of 6 checks passed
@BPScott BPScott deleted the remove-jest-extended branch September 23, 2024 22:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants