Skip to content

feature: implement toHaveStyle Jest matcher #1484

Closed
@mdjastrzebski

Description

@mdjastrzebski

Describe the Feature

toHaveStyle is a Jest DOM matcher asserting that given element has certain CSS styles.

We also have toHaveStyles already implemented in Jest Native. So migrating it to current repo, updating code to use RNTL helpers and reviewing TS types + tests quality should be the scope for the task.

Possible Implementations

Proposed API:

export function toHaveStyle(
  this: jest.MatcherContext,
  element: ReactTestInstance,
  style: StyleProp<ViewStyle | TextStyle | ImageStyle>,
) {

The matcher should:

  1. Validate that it is invoked on a host element
  2. Check if given element contains all of the passed state entries.

Each matcher should have a fairly comprehensive test suite.

Related Issues

#1454

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions