Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/paldepind/fake-raf

A fake requestAnimationFrame perfect for unit testing.
https://github.com/paldepind/fake-raf

Last synced: 15 days ago
JSON representation

A fake requestAnimationFrame perfect for unit testing.

Awesome Lists containing this project

README

        

# fake-raf

A fake `requestAnimationFrame`, i.e. a stub for unit testing.

* Very simple
* Supports TypeScript

## Usage

```js
import * as fakeRaf from "fake-raf";

fakeRaf.use(); // install global mock

function loop() {
// do stuff here
requestAnimationFrame(loop);
}
requestAnimationFrame(loop);

fakeRaf.step(); // call all listeners
fakeRaf.step();
fakeRaf.step();

fakeRaf.restore(); // restore the real `requestAnimationFrame`
```