Reputation: 81
I'm using React, Enzyme and Jest. This is my connect component which only renders a button
import { connect } from 'react-redux';
import { withStyles } from '@material-ui/core/styles';
import PlaidLinkButton from 'react-plaid-link-button';
const plaidEnv = process.env.REACT_APP_PLAID_ENV
export class ConnectStep extends Component {
handleOnSuccessBroker = async (token, metadata) => {
//unimportant
};
render() {
const { classes } = this.props;
return (
<PlaidLinkButton
buttonProps={{
className: classes.connectButton,
id: 'button',
}}
plaidLinkProps={{
clientName: '###',
key: '###',
env: plaidEnv,
product: ['transactions'],
onSuccess: this.handleOnSuccessBroker,
token: ''
}}
>
{this.props.plaid.accounts.length > 0 ? 'CONNECTED' : 'Start'}
</PlaidLinkButton>
);
}
}
As you can see Im importing PlaidLinkButton but jest throws this error:
###/node_modules/react-plaid-link-button/dist/react-plaid-link-button/react-plaid-link-button.js:19
import PropTypes from 'prop-types';
^^^^^^^^^
SyntaxError: Unexpected identifier
4 |
5 | import { setPlaid } from '../../../actions/actions';
> 6 | import PlaidLinkButton from 'react-plaid-link-button';
What am I missing? I made successful test suites for other components that also import modules. But this one in particular is giving me problems.
Upvotes: 1
Views: 845
Reputation: 2517
import PropTypes from 'prop-types';
^^^^^^^^^
SyntaxError: Unexpected identifier
This is likely an issue related to your Jest/Babel config because the modules aren't getting compiled correctly. You'd need to remove anywhere you set the Babel option modules to false
.
Related: https://github.com/facebook/react/issues/14399
Upvotes: 1