Skip to content

Using the wrong 'waitFor' gives a warning about the wrong 'act' #560

@kirkobyte

Description

@kirkobyte
  • react-hooks-testing-library version: 5.0.3
  • react version: 16.13.1
  • react-dom version (if applicable): 16.13.1
  • node version: 14.13.1
  • npm (or yarn) version: 1.22.4

Relevant code or config:

import {waitFor} from '@testing-library/react';
import {renderHook} from '@testing-library/react-hooks';

it('does a thing', async () => {
  const {result} = renderHook(() => useTestHook());
  await waitFor(() => expect(result.something).toBe(true));
});

What you did:

Used the wrong version of waitFor

What happened:

The console gave a warning for using the wrong version of act.

Problem description:

While it is true that the wrong version of act is used, it is only used inside of the waitFor here. Which can make it difficult to see where the wrong version of act is coming from.

Suggested solution:

An ESLint rule to check and warn on usage of the wrong waitFor in the same test block?
It seems that the current warning comes from React/React-DOM. Would it be possible to add another warning here on in react-testing-library's waitFor to provide more information?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestneeds more inforequire more information before we can action

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions