Skip to content

Latest commit

 

History

History
40 lines (22 loc) · 1.65 KB

Generating Jest Mocks.md

File metadata and controls

40 lines (22 loc) · 1.65 KB

Generating new Jest Mocks

This document will guide you through the process of generating new Jest Mocks for packages/jest-expo module using apps/jest-expo-mock-generator.

Why

We provide some mocks of our native methods which are generated by traversing all the modules and its methods and making a configuration of all those methods with the number of arguments etc.

How

  1. In your terminal, go to apps/jest-expo-mock-generator
  • run yarn to ensure the dependencies are installed
  • run expo start to start the Expo server
  1. Open the Expo Go project on iOS by opening ios/Exponent.xcworkspace
  • run the project on a simulator or a device
  1. Open jest-expo-mock-generator in the running Expo Go app

  2. After the app is finished opening, in the terminal, where the Expo server is running, you should see a big chunk of text wrapped with

    ------------------------------COPY THE TEXT BELOW------------------------------

    and

    ------------------------------END OF TEXT TO COPY------------------------------

    lines. Select and copy the text from between those lines.

jest-expo-mocks.mp4
  1. Stop the Expo server running in apps/jest-expo-mock-generator, started in step 1.

  2. Paste the copied text into packages/jest-expo/src/preset/expoModules.js.

  3. In the terminal, go into packages/jest-expo.

  4. Run yarn prettier src/preset/expoModules.js --write.

  5. Commit the changes. Bonus points for not modifying mock values (like deviceYearClass), which will be different if you use a test device different than the one used before.