Skip to content

toHaveClass(..., { exact: true })'s Received/Expected output is buggy #397

Closed
@nstepien

Description

@nstepien
  • @testing-library/jest-dom version: 5.14.1
  • node version: v16.7.0
  • npm (or yarn) version: 7.21.0
  • @testing-library/react version: 12.0.0

Relevant code or config:

expect(document.body).toHaveClass('abc', { exact: true });

What you did:

Testing an element's exact class

What happened:

When the assertion fails, the output is garbled:

image

Reproduction:

See relevant code above.

Problem description:

Well it's not the expected output that's for sure.

Suggested solution:

Should work similarly to when exact: false is used:

image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions