Reputation: 1253
I am having the following error when running Jest
SyntaxError: node_modules/my_styleguide/src/components/blocks/SegmentSetting.jsx: Unexpected token (46:10)
44 | ) {
45 | return (
> 46 | <p className="SettingDescr">{self.props.description}</p>
| ^
47 | )
48 | }
49 | }
The node_modules dependency is still in its es6 format. Jest doesn't seem to provide the option to transpile your node_modules, as it does with your actual app. Instead, jest ignores the node_modules folder.
The .bashrc file looks ok to me:
{
"presets": ["es2015", "react", "stage-0"]
}
How do you make Jest transpile your node_modules too? It would be the equivalent of the "--ignore false" flag that we have in mocha.
Upvotes: 3
Views: 2389
Reputation: 8494
I would mark this as an answer rather than the answer.
I had a similar issue, multiple components in node_modules in ES2015 and in need of transpilation.
I updated transformIgnorePatterns
to:
["/node_modules/(?!(our-react-components-.*?\\.js$))"]
The negative look-ahead for modules in our-react-components-*
folders mean Jest (and therefore Babel) will find and transpile our shared components.
This was in an ejected Create React App project with Jest 20.0.4.
Upvotes: 3