Skip to content

[IMP] tests: add tests for custom jest matchers#8841

Open
hokolomopo wants to merge 2 commits into
masterfrom
master-jest-custom-matchers-tests-adrm
Open

[IMP] tests: add tests for custom jest matchers#8841
hokolomopo wants to merge 2 commits into
masterfrom
master-jest-custom-matchers-tests-adrm

Conversation

@hokolomopo
Copy link
Copy Markdown
Contributor

@hokolomopo hokolomopo commented Jun 3, 2026

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.

  • 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.

[REF] tests: remove custom toBeCloseTo matcher

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

review checklist

  • feature is organized in plugin, or UI components
  • support of duplicate sheet (deep copy)
  • in model/core: ranges are Range object, and can be adapted (adaptRanges)
  • in model/UI: ranges are strings (to show the user)
  • undo-able commands (uses this.history.update)
  • multiuser-able commands (has inverse commands and transformations where needed)
  • new/updated/removed commands are documented
  • exportable in excel
  • translations (_t("qmsdf %s", abc))
  • unit tested
  • clean commented code
  • track breaking changes
  • doc is rebuild (npm run doc)
  • status is correct in Odoo

@robodoo
Copy link
Copy Markdown
Collaborator

robodoo commented Jun 3, 2026

Pull request status dashboard

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
@hokolomopo hokolomopo force-pushed the master-jest-custom-matchers-tests-adrm branch from d67eea2 to 98328ee Compare June 3, 2026 11:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants