I am getting the following error:
Cannot find module 'setupDevtools' from 'setup.js'
at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:169:17
My JSON.package file looks like this:
{
"name": "MiBase",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"babel-preset-env": "^1.7.0",
"i": "^0.3.6",
"jest-react-native": "^18.0.0",
"react": "16.3.1",
"react-native": "0.55.3",
"react-native-datepicker": "^1.7.2",
"react-native-image-picker": "^0.26.7",
"react-native-ui-xg": "0.0.6",
"react-navigation": "^1.5.11"
},
"devDependencies": {
"babel-jest": "^22.4.3",
"babel-preset-react-native": "3.0.0",
"jest": "22.4.3",
"react-test-renderer": "^16.3.1"
},
"jest": {
"preset": "react-native",
"moduleNameMapper": {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__tests__/loginTest.js",
"\\.(css|sass)$": "<rootDir>/__tests__/loginTest.js"
},
"transformIgnorePatterns": [
"node_modules"
],
"coveragePathIgnorePatterns": [
"node_modules"
],
"modulePathIgnorePatterns": [
"node_modules"
]
}
}
My test file looks like this:
// __tests__/loginTest.js
import 'react-native';
import React from 'react';
import HomeSreen from '../App';
import renderer from 'react-test-renderer';
test('renders correctly', () => {
const tree = renderer.create(<LoginScreen />).toJSON();
expect(tree).toMatchSnapshot();
});
I am very new to React Native and even newer to testing with it. Everything I have learnt or have tried to solve this issue has come from these three places:
https://facebook.github.io/jest/docs/en/tutorial-react-native.html Jest Cannot find module 'setupDevtools' from 'setup.js' Jest - Cannot find module 'setupDevtools' from 'setup.js'
I also have other functions in the class that I am not trying to test at this point. I am only trying to test the GUI functionality and that everything displays correctly. These functions are for processing http responses and JSON parsing.