Skip to content

Bug: react-test-renderer: promise returned from findByProps query must be handled #23093

Closed

Description

@josias-r

React (and react-test-renderer) version: 17.0.2
Eslint version: 8.6.0

Steps To Reproduce

  1. create a ReactTestInstance using create from react-test-renderer
  2. Try to run access findByProps of the root of ReactTestInstance
  3. Eslint(testing-library/await-async-query) will show an error

code example:

// simulate nav toggle click event
create(<Nav onToggle={mockFunction} items={[]}></Nav>)
  .root.findByProps({
    className: "app__nav-toggler",
  })
  .props.onClick();

The current behavior

Eslint(testing-library/await-async-query) will show an error:

Screenshot 2022-01-11 at 11 57 52

Screenshot 2022-01-11 at 12 00 31

The expected behavior

Since the return type of findByProps is not actually a promise, the error should not appear. findByProps appears to be synchronous.

Activity

  1. added
    Status: Unconfirmed
    on Jan 11, 2022
  2. bvaughn commented on Jan 11, 2022

    @bvaughn
    Contributor

    The lint rule in your bug report (testing-library/await-async-query) is for another project, testing-library. That library (and lint rule) are not related to the findByProps method of react-test-renderer. I think the lint rule, in this case, is just a false positive because the method name starts with "findBy".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: Unconfirmed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions