Open HugoLiconV opened 4 years ago
I added this to my package.json
"jest": {
"transformIgnorePatterns": [
"node_modules/(?!(react-native|react-native-vector-icons|@react-native-community/picker)/)"
],
}
After adding this, you'll get this error: TypeError: Cannot read property 'default' of undefined
. To solve it go to node_modules/@react-native-community/picker/js/PickerIOS.ios.js
and add a constructor to the PickerIOS component:
class PickerIOS extends React.Component<Props, State> {
_picker: ?ElementRef<RNCPickerIOSType> = null;
+ constructor(props) {
+ super(props)
+ }
state = {
selectedIndex: 0,
items: [],
};
// ...
Thanks @HugoLiconV, adding constructor was not required but adding @react-native-community/picker
to transformIgnorePatterns
helped.
In case anyone else still experiences problems with the above, I found the secret sauce for me was:
"transformIgnorePatterns": [
"node_modules/(?!(jest-)?react-native|@react-native-community|@react-native-picker)",
],
In case anyone else still experiences problems with the above, I found the secret sauce for me was:
"transformIgnorePatterns": [ "node_modules/(?!(jest-)?react-native|@react-native-community|@react-native-picker)", ],
Make sure you add this under "jest" in package.json or jest config Works for me. Thanks
To fix the unexpected token error, I updated the config-overrides.js with:
module.exports = override(
babelInclude([
...
path.resolve('src'),
path.resolve(__dirname, 'node_modules/@react-native-picker/picker'),
]),
);
Still seeing this issue, even if using transformIgnorePatterns
Just in case it helps. I had the same issue because I was using expo-image-picker
my solution was to also ignore expo-modules-core
.
Just in case it helps. I had the same issue because I was using
expo-image-picker
my solution was to also ignoreexpo-modules-core
.
I was seeing this issue without using expo-image-picker
.
Bug report
Summary
When I run the test I get this error:
Environment info
react-native info
output:Library version: 1.6.1
Steps to reproduce
npm test