Jump to content
Search Community

Jest testing TimelineLite, issue

Evolution Latvia test
Moderator Tag

Recommended Posts

Hello,

I have try to migrate project from gsap2 to gsap3.

I faced with issue while run jest tests.

`index.ts

import { TimelineLite } from "gsap";
 
const timeline = new TimelineLite();
timeline.paused(true);
 
export const init = (fn: () => void) => {
timeline.call(fn, ['123'], "label");
timeline.play();
}

`

`

index.spec.ts

import { init } from './index';
 
describe('When multiplying numbers', () => {
it('Should call', () => {
const mock = jest.fn();
init(mock);
setTimeout(() => expect(mock).toHaveBeenCalledWith('123'), 50);
});
});

`

 

This test is passing for gsap2 and don't passing for gsap3.

When i remove `

timeline.paused(true);

then it starts passing for gsap3.

Why?

Attached full code.

 

typescript-jest-boilerplate.zip

Link to comment
Share on other sites

1 hour ago, GreenSock said:

should be fixed in the next release which you can preview at https://s3-us-west-2.amazonaws.com/s.cdpn.io/16327/gsap-latest-beta.min.js

 

Here's a version that you can install for your project. First uninstall gsap and @types/gsap. The types are already included with gsap's npm package, so you should NEVER install @types/gsap for v3 or higher. 

 

Now install gsap like this.

npm install https://s3-us-west-2.amazonaws.com/s.cdpn.io/16327/gsap-beta.tgz

 

And you should be good to go.

 

  • Like 3
Link to comment
Share on other sites

And you don't need to use TimelineLite/TimelineMax or TweenLite/TweenMax for v3. They are just aliases.

 

import { gsap } from "gsap";
 
const tween = gsap.to(".foo", { x: 100 }); // Same as TweenLite/TweenMax

const timeline = gsap.timeline(); // Same as TimelineLite/TimelineMax
timeline.paused(true);
 
export const init = (fn: () => void) => {
timeline.call(fn, ['123'], "label");
timeline.play();
}

 

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...