Closed branberry closed 11 months ago
Hey @ckifer ! Do you mean something like !!requestAnimationFrame
? I haven't tried that, but when I was debugging this code in the Vitest tests, doing the following still gave me the requestAnimationFrame is undefined error:
if (!requestAnimationFrame) { ... }
Typically wouldn't do the whole typeof
stuff, but for whatever reason, this was the only way to ensure that it wouldn't error out when checking.
Weird yeah the second way is what I was thinking should work? Strange... generally I would think libraries shouldn't have to adjust for a test framework but.. makes sense I guess?
Yeah.. It was really bizarre. I think it's all related to VItest interacting with the react-testing-library which leads to fake timers not working: https://github.com/testing-library/react-testing-library/issues/1198
When making the tests async, stuff just didn't want to behave nicely for the animated tests, and the library would still be calling requestAnimationFrame
after the tests have completed, so I think this is why we ran into this. I also debugged into some gnarly Vitest code, and it looked like that was the case.
JsDom in general is probably a lot of the issue because everything animation and actual dom testing wise needs to be mocked
Fixes test issues with Vitest in Recharts