Skip to content

SVG elements fail on most matchers #28

@jgoz

Description

@jgoz
  • jest-dom version: 1.5.1

  • node version: 8.11.3

  • npm (or yarn) version: yarn 1.7.0

  • dom-testing-library version: 2.7.0

  • react-testing-library version: 4.1.2

Relevant code or config:

expect(someSvgElement).toHaveClass("any-class");

What you did:

  • Make expect calls on SVG elements

What happened:

Exception thrown because they are not HTML elements.

Problem description:

Most assertions defined in this library would also be applicable to SVG elements, but they are being blocked unnecessarily.

Suggested solution:

Modify checkHtmlElement to allow elements that satisfy instanceof SVGElement.

I'm happy to open a PR if no one opposes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions