2.1.2 • Published 2 years ago

mock-request-animation-frame v2.1.2

Weekly downloads
22
License
ISC
Repository
github
Last release
2 years ago

Mock Request Animation Frame

Installation

yarn add -D mock-request-animation-frame

or

npm i -D mock-request-animation-frame

Disclaimer

These helper functions are intended to be used with Jest.

Getting started

This module now comes with 2 helper functions! Specially designed for tests on components that use Adobe React Spectrum.

  1. mockRequestAnimationFrame - It will fully mock a request animation frame (RAF). There are various components that leverage RAFs for rendering causing tests to break.

  2. mockClientWindow - It will mock the height and width of the window object. Some components need dimensions for rendering, also breaking jest tests if not mocked.

You will have to call this helper functions in each test file that will encounter a RAF or needs window dimensions while executing.

Behind the scenes these functions use beforeEach, afterEach, beforeAll and afterAll thus it may be run at the top level of the file or at the top level of your describe statements see the examples below for more details.

Examples

// one-of-your-test-files
import { mockRequestAnimationFrame } from "mock-request-animation-frame";

mockRequestAnimationFrame();

// Run your tests here

or

import { mockClientWindow } from "mock-request-animation-frame";

describe("example test", () => {
    mockClientWindow();

    // Run your tests here
});

       

Happy testing! 🔬

1.1.1

2 years ago

1.1.0

2 years ago

2.1.2

2 years ago

2.1.1

2 years ago

2.1.0

2 years ago

2.0.0

2 years ago

1.0.5

2 years ago

1.0.4

4 years ago

1.0.2

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago