react-native-root-toast
react-native-root-toast copied to clipboard
Error on running jest tests
/Users/user/dir/node_modules/static-container/StaticContainer.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import React, { Component, Children, PropTypes } from 'react';
^^^^^^
SyntaxError: Unexpected token import
at transformAndBuildScript (node_modules/jest-runtime/build/transform.js:320:12)
at Object.<anonymous> (node_modules/react-native-root-siblings/lib/AppRegistryInjection.js:3:22)
at Object.<anonymous> (node_modules/react-native-root-siblings/lib/SiblingsManager.js:3:27)
I find this error to be invoked by using package react-native-root-siblings which in new release is using static-container package which is not transformed with babel.
Quick fix is to install older version of package npm install [email protected]
Thanks!
you could use this as a work around too
"jest": {
"preset": "react-native",
"transformIgnorePatterns": [
"node_modules/?!(react-native-root-siblings)"
]
}
ignore react-native-root-siblings didn't work for me, but ignore static-container works.
"jest": {
"preset": "react-native",
"transformIgnorePatterns": [
"node_modules/(?!static-container)"
]
},
same as @dongyuwei
you could use this as a work around too
"jest": { "preset": "react-native", "transformIgnorePatterns": [ "node_modules/?!(react-native-root-siblings)" ] }
Not working, please help me how can test the component. If I remove this then all works fine.
ignore react-native-root-siblings didn't work for me, but ignore
static-containerworks."jest": { "preset": "react-native", "transformIgnorePatterns": [ "node_modules/(?!static-container)" ] },
This is a good workaround but is only necessary because the authors of this library don't pre-compile their files. This is sadly one for the static-container maintainers so this should probs be closed with some docs added to the README.
How about this
"transformIgnorePatterns": [
"/node_modules/(?!react-native)/.+"
],