Why do I get an "Unexpected identifier" error running "mount component" Jest test with react-vis chart?

Viewed 343

I'm trying to run a basic "mount React component" test in Jest. The test is

test("Create App component", () => {
  const div = document.createElement("div");
  ReactDOM.render(<App />, div);
  ReactDOM.unmountComponentAtNode(div);
});

The test infrastructure was set up using create-react-app.

The App component has a child that uses react-vis components.

When I try to run the test, I get the following error

import _AbstractSeries from './plot/series/abstract-series';
        ^^^^^^^^^^^^^^^

    SyntaxError: Unexpected identifier

    2 | import PropTypes from "prop-types";
    3 | import { withStyles } from "@material-ui/core/styles";
    > 4 | import {
        | ^
    5 |   AreaSeries,
    6 |   Crosshair,
    7 |   CustomSVGSeries,

    at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/script_transformer.js:403:17)
    at Object.<anonymous> (src/components/Charts/MyCustomChart.js:4:1)

Any advice on how to get this test working?

1 Answers
Related