0
const enhance = compose(
mapStateToProps,
withRouter,
withApollo
)
export default enhance(ManagePublicTable)
In the archive Managepublictable.spec.js I’m importing the component as:
import { ManagePublicTable } from './ManagePublicTable'
But he makes a mistake:
Invariant Violation: Element 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.
Check the render method of `WrapperComponent`.
67 | it("should render hooks in manage public table admin's component", function() {
68 |
> 69 | const filter= mount(<ManagePublicTable {...props}></ManagePublicTable>);
| ^
70 | expect('name').toBe(props.sortBy)
71 |
72 | });
The test:
describe('ManagePublicTable', () => {
const mapStateToProps = state => {
return {
loading: false,
tableRows: {},
sortBy: 'name',
sortDirection: 'ASC',
searchIsFocused: false,
showModalActivityBasicDetails: false,
currentActivityInModalBasicDetails: {}
}
}
let props
beforeEach(() => {
props = {
mapStateToProps,
withRouter,
withApollo
}
});
it("should test the sort element", function() {
const filter= mount(<ManagePublicTable {...props}></ManagePublicTable>);
expect('name').toBe(props.sortBy)
});
})