khanglu / react-crossfade-image

react-crossfade-image - Simple React component for crossfading images - No CSS needed
MIT License
33 stars 13 forks source link

Failing Jest tests #4

Open JPStrydom opened 6 years ago

JPStrydom commented 6 years ago

Whenever I have this package imported in a file, Jest gives me the following error message for that file:

SyntaxError: Unexpected identifier

import React, { Component } from "react";
       ^^^^^

I tried adding it as a transform ignore pattern, but it didn't work.

Any idea how to fix t?

GChin12 commented 6 years ago

I am experiencing the same issue.

JPStrydom commented 6 years ago

I managed to temporarily solve the issue by having the following in my jest-setup.js file:

import React from 'react';
import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';

configure({ adapter: new Adapter() });

jest.mock('react-crossfade-image', () => <div />);

This isn't an ideal solution, but it works for the time being.