I am trying to test my component which is nothing fancy. But when I import it in the test file and try to load it I get the following error
Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: symbol.
Here is my code:
import React from 'react';
import { mount } from 'enzyme';
import sinon from 'sinon';
import AuditInvestigator from './AuditInvestigator';
import axios from 'axios';
describe('Test Audit Investigator ', () => {
let wrapper;
beforeEach(() => {
wrapper = mount(<AuditInvestigator />)
})
it('should contain state', () => {
expect(wrapper.state()).toEqual({
cancelToken: axios.CancelToken.source()
})
})
})
If you have any ideas I am open, or you need more info of my code I will provide it.
EDIT: AuditInvestigator Content:
import React from 'react';
import PropTypes from 'prop-types';
import autoBind from 'react-autobind';
import { AuditInvestigatorLayout } from './AuditInvestigatorLayout';
import { reworkRawAllActivityLogsData, reworkUsersData } from '../.././utils/rework-activity-log-data';
import axios from 'axios';
class AuditInvestigator extends React.Component {
constructor(props) {
super(props);
autoBind(this);
this.state = {
cancelToken: axios.CancelToken.source()
}
}
componentWillMount = () => {
this.props.requestAllUsers();
if(this.props.selectedUser.value !== '0') {
this.props.requestAllLogs({cancelToken: this.state.cancelToken, userId: this.props.selectedUser.value});
}
}
onGridReady(params) {
this.gridApi = params.columnApi;
}
componentDidUpdate = () => {
if (this.gridApi) {
var allColumnIds = [];
this.gridApi.getAllColumns().forEach(function(column) {
allColumnIds.push(column.colId);
});
this.gridApi.autoSizeColumns(allColumnIds);
}
};
componentWillUnmount = () => {
this.state.cancelToken.cancel('operation canceled')
this.props.requestAllLogsSuccess({logsData: []})
}
onUsersSelectChange = (e) => {
this.props.changeLogsUser(e);
this.props.requestAllLogs({cancelToken: this.state.cancelToken, userId: e.value});
}
render() {
return (
<div>
<AuditInvestigatorLayout
hideLogsLoader={this.props.hideLogsLoader}
logsData={reworkRawAllActivityLogsData(this.props.logsData)}
onGridReady={this.onGridReady}
usersData={reworkUsersData(this.props.usersData)}
onUsersSelectChange={this.onUsersSelectChange}
usersHideLoader={this.props.usersHideLoader}
selectedUser={this.props.selectedUser}
/>
</div>
);
}
}
AuditInvestigator.propTypes = {
hideLogsLoader: PropTypes.bool,
logsData: PropTypes.array,
requestAllLogs: PropTypes.func,
history: PropTypes.object,
requestAllLogsSuccess: PropTypes.func,
requestAllUsers: PropTypes.func,
selectedUser: PropTypes.object,
changeLogsUser: PropTypes.func,
usersData: PropTypes.array,
usersHideLoader: PropTypes.bool
};
export default AuditInvestigator;