Yahwe Raj
Yahwe Raj

Reputation: 2057

How to test requestAnimationFrame with jasmine(2.4) testing?

I am new in jasmine testing and I have searched the test case example for requestAnimationFrame in jasmine document, but I couldn't find it.

I found this plugin to create mock requestAnimationFrame, but I need to use jasmine inbuilt option to test requestAnimationFrame.

Is there any option to test the requestAnimationFrame with jasmine using inbuilt functionalities?

Upvotes: 4

Views: 2181

Answers (1)

kiewic
kiewic

Reputation: 16450

Use setTimeout() and done():

it("Spec with requestAnimationFrame", (done) => {
    window.requestAnimationFrame(() => {
        // Do something testable here
    });

    setTimeout(function() {
        // Verify testable values here

        done();
    }, 200);
});

Upvotes: 2

Related Questions