lundi 20 mai 2019

How to test a react component which uses react-spring?

I'm trying to test my IdeaCarousel component. This component uses react-spring for animations. When I run my test I get the following error:

"Jest encountered an unexpected token".

If I comment my Spring code the error disappears and my test passes.

This is the testing code:

import React from "react";
import IdeaCarousel from "../components/IdeaCarousel";


test('renders without crashing', () => {
    expect(true).toBeTruthy();
});

And the IdeaCarousel code:

<Spring
  from=
  to=
>
  {props => <div style={props}>
    ...just some code...
  </div>}
</Spring>

I wonder what I must do to test this code. Should I mock something?

Aucun commentaire:

Enregistrer un commentaire