Git Product home page Git Product logo

react-native-jest-mocks's Introduction

React Native Jest Mocks

Collection of Jest mocks for React Native that I use for different projects.

Usage

1.- First, install the package.

yarn add --dev react-native-jest-mocks

or

npm install --save-dev react-native-jest-mocks

2.- If you haven't already, create a jest-setup.js file in the root of your project.

3.- Afterwards, inside your package.json file, in the jest section, reference your setup file:

"jest": {
  "preset": "react-native",
  "setupFiles": [
    "./jest-setup.js"
  ]
}

4.- Now, inside your jest-setup.js file import the module:

import mocks from 'react-native-jest-mocks'

5.- And init the mocks:

mocks.initAll();

You can also check the Example App

Mocks currently included:

  • navigator global
  • Linking
  • ScrollView
  • YellowBox
  • react-native-localize
  • console.error: This is currently included to avoid some warnings from react-navigation.

License

MIT

react-native-jest-mocks's People

Contributors

davidpricedev avatar dependabot[bot] avatar keyserfaty avatar tommahle avatar xabadu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.