Skip to content

[BUG] Single test fails #1083

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kevcenteno opened this issue Aug 18, 2023 · 5 comments
Closed

[BUG] Single test fails #1083

kevcenteno opened this issue Aug 18, 2023 · 5 comments
Labels

Comments

@kevcenteno
Copy link

kevcenteno commented Aug 18, 2023

Bug description
Test suites with only one test fail.

Version of Package
v5.21.1 but behaviour first seen in v5.20.0

To Reproduce
Delete all tests in src/test/tooltip-props.spec.js except for "basic tooltip". Update snapshots to reduce noise.

OR

Replace test with test.only instead of deleting all the other tests.

Test run results in failure:

$ jest src/test/tooltip-props.spec.js
 FAIL  src/test/tooltip-props.spec.js
  tooltip props
    ✕ basic tooltip (1295 ms)

  ● tooltip props › basic tooltip

    Unable to find role="tooltip"

    Ignored nodes: comments, script, style
    <body>
      <div>
        <span
          id="basic-example"
        >
          Lorem Ipsum
        </span>
      </div>
    </body>

      24 |     let tooltip = null
      25 |
    > 26 |     await waitFor(() => {
         |                  ^
      27 |       tooltip = screen.getByRole('tooltip')
      28 |       expect(tooltip).toHaveAttribute('style')
      29 |     })

      at waitForWrapper (node_modules/@testing-library/dom/dist/wait-for.js:166:27)
      at Object.<anonymous> (src/test/tooltip-props.spec.js:26:18)

Expected behavior
Test should pass

Desktop (please complete the following information if possible or delete this section):

  • OS: ubuntu
@kevcenteno kevcenteno added the Bug label Aug 18, 2023
@kevcenteno
Copy link
Author

3b411f0 is the offending commit

@kevcenteno
Copy link
Author

Any traction on this?

@gabrieljablonski
Copy link
Member

@kevcenteno we're planning on overhauling the test suites soon, since there's been issues with inconsistency not just with this one.

Until then, if you think of any easy fixes for this one, we'd really appreciate suggestions or even a PR.

Copy link

github-actions bot commented Jan 4, 2024

This issue is stale because it has not seen activity in 30 days. Remove the stale label or comment within 14 days, or it will be closed.

@github-actions github-actions bot added the Stale This has not seen activity in quite some time label Jan 4, 2024
@gabrieljablonski gabrieljablonski removed the Stale This has not seen activity in quite some time label Jan 4, 2024
@gabrieljablonski
Copy link
Member

Working on some test refactoring on #1171. Everything seems to be working now.

For future reference, when testing the tooltip NOT to be on screen, we recommend the following (using @testing-library/react):

await waitFor(() => {
  expect(screen.queryByRole('tooltip')).not.toBeInTheDocument()
})

When getting a reference to the tooltip, we recommend this:

const tooltip = await screen.findByRole('tooltip')
expect(tooltip).toHaveAttribute('style')

Waiting for the tooltip to have the react-tooltip__show (or react-tooltip__closing) class is often not necessary, but may be useful when testing both opening and closing the tooltip on the same spec.

await waitFor(() => {
  // also useful with `react-tooltip__closing`
  expect(screen.queryByRole('tooltip')).toHaveClass('react-tooltip__show')
})

Will be closing this for now. Please open a new issue if you have further problems with writing tests for the tooltip. The internal tooltip tests should all pass after #1171 is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants