mockaf
Mocks *AnimationFrame methods.
Motivation
When unit testing, it can sometimes be useful to mock the *AnimationFrame methods if the code under test makes use of them. Using mockaf
allows us to execute *AnimationFrame callbacks in the same tick of the event loop, making the tests a little easier to write.
Installation
$ npm install mockaf
Example
var mockaf = ; // Mock all window *AnimationFrame methods.mockaf; // Schedule stuff.window; // Schedule more stuff.var id = window; // Cancel the last callback.window; // Execute any callbacks stored since the last tick.mockaf; // Restore original window.*AnimationFrame methods.mockaf;
API
var mockaf = ;
mockaf.install()
Install mock implementations of all *AnimationFrame methods available on the window object.
mockaf.tick()
Execute any callbacks stored via the mocked *AnimationFrame methods since the last tick.
mockaf.uninstall()
Restore original *AnimationFrame methods on the window object.
Tests
$ npm test
Credits
License
MIT