flopflip: ConfigureFlopflip causes act error warnings in test environment
Describe the bug
It seems that <ConfigureFlopflip> still triggers state updates, causing act error warnings when running tests.
To Reproduce See https://github.com/commercetools/merchant-center-application-kit/pull/1340
Expected behavior
No act warnings when running tests
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 15 (14 by maintainers)
I think it’s due to the usage of functional components with hooks and the async behavior. And given that this behavior resembles more the real usage, it just shows that our tests setup has been “incorrect and fragile” this all time.
Thanks for digging deeper. I agree that beforeEach can often just be achieved with „smarter“ ways of using render-fns/helpers and that it usually eases things.
Still wondering what actually is so strange on a beforeEach and why it works so „different“ from how one could hope and when similar edge cases exist without flopflip specifically. As you said they exist. Just wondering what specifically triggers them.
I right now also don’t think flopflip can do much immediately. Maybe I can play around a bit more at some point as we have a repro case.
I’m starting to think that the implementation of
<Configure>is just fine and the problem relies on usingbeforeEach. I also found an article by Kent saying that he also does not like using those hooks.https://kentcdodds.com/blog/test-isolation-with-react
I actually agree with that and can also relate as I bumped into similar issues when I was refactoring/fixing tests in the MC, as we used to do that previously with enzyme. Getting rid of using
beforeEachor nested describes solved most of the issues.I would say that we should just write our tests in a more “isolated” way. I’ll try that in appkit and see if it solves the issues.