react-email-editor icon indicating copy to clipboard operation
react-email-editor copied to clipboard

Enzyme test fails when using react-email-editor and TypeScript

Open jimmy-e opened this issue 6 years ago • 2 comments

To Reproduce

Clone this repo. Run yarn. Run yarn test.

Expected behavior

The test should pass with no warning. Although the test passes, doing other tests with the EmailEditor component will fail for the same reason as the warning given:

React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

Code

unlayer.tsx:

import * as React from 'react';
import EmailEditor from 'react-email-editor';

const Unlayer: React.FC = () => <EmailEditor />;

export default Unlayer;

unalyer.test.tsx:

import * as React from 'react';
import { shallow } from 'enzyme';
import Unlayer from './unlayer';

test('component renders', () => {
  expect(shallow(<Unlayer />).length).toBe(1);
});

jimmy-e avatar Oct 16 '19 18:10 jimmy-e

@adeelraza is there any update on this?

jimmy-e avatar Mar 27 '20 14:03 jimmy-e

3 years later and still no response!

are there ANY examples of testing? can't seem to find any tests in the source of the EmailEditor component either!

sorsaffari avatar Jun 13 '22 15:06 sorsaffari