Open Thegrep01 opened 3 years ago
any solution? , i am facing the same
Create a file __jest__/assetTransformer.js
. (You can create the file anywhere in the project, make sure to fix the path in package.json)
const path = require('path');
module.exports = {
process(src, filename, config, options) {
return 'module.exports = ' + JSON.stringify(path.basename(filename)) + ';';
},
};
now edit jest
key of package.json or edit jest config file (whichever you have)
"jest": {
"preset": "react-native",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
],
+ "transformIgnorePatterns": [
+ "node_modules/(?!(@react-native|react-native|react-native-iphone-x-helper)/)"
+ ],
+ "moduleNameMapper": {
+ "\\.(jpg|jpeg|png|gif)$": "<rootDir>/__jest__/assetTransformer.js"
+ }
}
In some units tests, it starts failing with logs