Skip to content

[BUG] Can't pass jest toBeVisible #1058

Closed as not planned
Closed as not planned
@rayandben2000

Description

@rayandben2000

Bug description
Even simple code can't pass jest toBeVisible (see To Reproduce section.)

Version of Package
v5.16.1

To Reproduce

Test Code:

it.only('test', async () => {
  const user = userEvent.setup({ advanceTimers: jest.runOnlyPendingTimers });
  const { getByTestId, getByText, getByRole } = render(
    <>
      <div data-testid="test" data-tooltip-id='test' data-tooltip-content='tooltip!'>test</div>
      <ReactTooltip id="test" />
    </>
  );

  expect(getByText('test')).toBeInTheDocument();

  await user.hover(getByTestId('test'));
  expect(getByRole('tooltip', {hidden: true})).toBeVisible();
});

Test Result:

    expect(element).toBeVisible()

    Received element is not visible:
      <div class="react-tooltip core-styles-module_tooltip__3vRRp styles-module_tooltip__mnnfp styles-module_dark__xNqje react-tooltip__place-top" id="test" role="tooltip" />

      357 |
      358 |       await user.hover(getByTestId('test'));
    > 359 |       expect(getByRole('tooltip', {hidden: true})).toBeVisible();
          |                                                    ^
      360 |
      361 |
      362 |     });


Expected behavior
Should pass toBeVisible

Addition information

  • jest: v29.5.0
  • @testing-library/react: 12.1.4

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