I have a React component importing another React HOC.
My React HOC:
import { withRouter } from "react-router";
...
const InnerComponent: FC<any> = (props): ReactElement => {
...
}
const withData = compose(
graphql(SOME_QUERY, {
props: mapProps,
options,
}),
injectIntl
);
export default withRouter(withX(withData(InnerComponent)));
My React Component:
export const OuterComponent: FC<any> = (props): ReactElement => {
...
return (
...
<InnerComponent />
...
)}
This is an excerpt from my test spec file (I use enzyme & jest):
const component = shallow(<OuterComponent {...props} />)
expect(component).toMatchSnapshot()
Locally, everything works fine. The part where my InnerComponent should be rendered is represented like this in the snapshot:
<withRouter() />
When I check-in my code and let it run on CI, snapshot test fails because that line in the snapshot CI generates looks like this:
<withRouter(_class) />
I am sure that enzyme and jest versions are same on CI and my machine. I even tried to update jest and enzyme on my machine but never got a snapshot having this weird _class
word.
Where does this _class
come from and how can I avoid it, or how can make sure that my local setup also generates it during snapshot creation?