Test React Native Apps with React Native Testing Library

Configuring Jest and React Native Testing Library

Last Updated: May 6, 2021

Please note that I've upgrade code to reflect the latest version of the library. All this means is that react-native-testing-library has been renamed to @testing-library/react-native. Everything else should be the same. The code below each video has been updated.

yarn add --dev jest@~26.6.3 jest-expo@~41.0.0 jest-fetch-mock@~3.0.3 @testing-library/react-native@~7.2.0

App/index.test.js

test('it works', () => {
  expect(true).toBeTruthy();
});

package.json

{
  // ...
  "jest": {
    "preset": "jest-expo",
    "transformIgnorePatterns": [
      "node_modules/(?!(jest-)?react-native|react-clone-referenced-element|@react-native-community|expo(nent)?|@expo(nent)?/.*|react-navigation|@react-navigation/.*|@unimodules/.*|unimodules|sentry-expo|native-base)"
    ]
  }
}

Want to track your progress? Create an account with React Native School!

Continue