Using jsdom with jsdom-global to test a program that uses requestAnimationFrame
. On first test I got
requestAnimationFrame is not defined
Then I added the window
namespace and still got that it was not defined. Is there no implementation for it on jsdom and is there a workaround?
Indeed this is not yet implemented in jsdom. You can always add a shim to window
, potentially before any parsing: https://github.com/tmpvar/jsdom#intervening-before-parsing
I wonder if we should implement this, with just a 1/60 of a second timer. Or is that too misleading, since jsdom does not paint the screen, ever?
Yes I think faking it with setTimeout would be great just to make code with it work. I bet no one would really ever expect it to have the original rAF behavior
Should also cancelAnimationFrame be made?
@asturur I think it'd be great to have cancelAnimationFrame
. I think a clearTimeout
should simulate that behavior.
Most helpful comment
Yes I think faking it with setTimeout would be great just to make code with it work. I bet no one would really ever expect it to have the original rAF behavior