I am writing an App using React Native, and I would like to test the App components with Tape and JSX syntax, so I think 'babel' is a must.
However when I run tape -r babel-register tests/**/*.js
, I received the infamous SyntaxError
with a PNG file.
/<redacted>/node_modules/react-native-router-flux/images/back_chevron.png:1
(function (exports, require, module, __filename, __dirname) { �PNG
SyntaxError: Invalid or unexpected token
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:152:10)
...
With an intention to search before asking, I have found a lot about ReactJS (which is about Webpack issues) and solutions with Jest (by setting jest
in package.json
).
.babelrc
{
"presets": [
"babel-preset-react-native-stage-0/decorator-support",
"react",
"es2015",
"stage-2"
],
"env": {
"development": {
"plugins": [
"transform-react-jsx-source"
]
}
}
}
Please feel free to comment on what logs / versions / config files I could add to this question! Thanks.