When I try using Jest for unit test, I got this error:
/node_modules/victory-native/lib/index.js:1
({"Object.
^^^^^^
SyntaxError: Unexpected token import
Is there any suggestion for this?
import is not supported by ES5, so it sounds like you don't have Jest configured to convert your ES6 to ES5 (or TypeScript to ES5 if you're using that).
See here for configuring Jest to work with Babel: https://facebook.github.io/jest/docs/getting-started.html#using-babel
see also: https://github.com/FormidableLabs/victory#jest-snapshots
you can fix it by using transformIgnorePatterns config
example
"jest": {
"preset": "react-native",
"transformIgnorePatterns": [
"node_modules/(?!victory-native)/"
]
},
I still think it's an issue that victory-native is published with the ES6 and not published with the ES5 compiled version tho