question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using `useFloating` with jest and testing-library

See original GitHub issue

Sorry for not using the sandboxes provided, but this is a problem that happens on the node environment, so I created a stackblitz

https://stackblitz.com/edit/node-75er2t?file=index.jsx

You can see that when rendering the <Floating /> component (code taken from docsite), there is immediately an error that states that something was not called in act. I think that this might be a consequence of computePosition being asynchronous.

It could be that I’m missing some kind of knowledge how to use floating-ui correctly in tests, but I keep getting this error even when try to use the least amount of code.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
atomikscommented, Aug 8, 2022

Docs explain: https://floating-ui.com/docs/react-dom#testing (I made an issue about this on testing-lib repo, but it doesn’t seem like they’ll change the timing of the cleanup function)

0reactions
atomikscommented, Aug 11, 2022

I forgot to respond somehow, yes a new issue with a minimal repro of the problem would be good

Read more comments on GitHub >

github_iconTop Results From Across the Web

Setup - Testing Library
In these docs we'll demonstrate configuring Jest, but you should be able to do similar things with any testing framework (React Testing ...
Read more >
@floating-ui/react-dom-interactions - npm
Start using @floating-ui/react-dom-interactions in your project by running `npm i ... @testing-library/jest-dom · @testing-library/react ...
Read more >
React - Floating UI
A JavaScript library for anchor positioning with web, React, and Vue bindings, plus interaction primitives for React to build floating UI components.
Read more >
Testing React Apps - Jest
At Facebook, we use Jest to test React applications. ... The following two examples use react-testing-library and Enzyme.
Read more >
How To Test a React App with Jest and React Testing Library
Obtaining solid test coverage is imperative for building confidence in your web application. In this tutorial, you will test asynchronous ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found