Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ktpm489/f14de1c4c94505f2aa2059f83d7d4aee to your computer and use it in GitHub Desktop.
Save ktpm489/f14de1c4c94505f2aa2059f83d7d4aee to your computer and use it in GitHub Desktop.
React Native common errors

Setting up react native test environment.

install React Native on global

npm install react-native-cli -g

create the project

react-native init <ProjectName>

npm install --save enzyme react-dom enzyme-adapter-react-16

add setupTests to configure Jest with enzyme

  • create a file setupTest.js:

        import { configure } from 'enzyme';
        import Adapter from 'enzyme-adapter-react-16';
        configure({ adapter: new Adapter() });
  • edit package.json:-

        "jest": {
          "preset": "react-native",
          "setupTestFrameworkScriptFile": "./setupTests.js",
        }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment