I have created a styled components in a sperate file with the same name and .css.jsx
for example Abc.jsx
have Abc.css.jsx
and it's imported to the Abc.jsx
to use. But when I try to test Abc.jsx
I get the below error,
Warning: 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.
Seems like React can't locate the styles written in my Abc.css.jsx
. Does anyone know the reason for this and how to fix this?
Abc.jsx
import * as Styled from './Abc.css';
function Abc() {
return (<Styled.Title>ABC</ Styled.Title>);
}
export default Abc
Abc.css.jsx
import styled from 'styled-components';
export const Title = styled.div`
`;
Abc.test.js
import Abc from '../../../components/Abc';
import { mount } from 'enzyme';
describe("My Abc tests", () => {
let wrapper;
beforeAll(() => {
wrapper = mount(<Abc />);
})
test("check api call", async () => {
})
});
from Jest, Enzyme and Styled Component not working with Warning: React.createElement
No comments:
Post a Comment