Skip to content

Latest commit

 

History

History
55 lines (36 loc) · 1.55 KB

Generating Jest Mocks.md

File metadata and controls

55 lines (36 loc) · 1.55 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. Go to apps/jest-expo-mock-generator
  • make sure it's yarned
  • run the Expo project (expo start)
  1. Open Expo Client project on iOS using ios/Exponent.xcworkspace
  • run project on the device
  1. Open jest-expo-mock-generator in Expo Client

  2. Copy big output that is printed between lines

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

and

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

  1. Paste/Save the above output into some file. DO NOT COMMIT THIS FILE! 😅 Clean after yourself!

OSX command:

pbpaste > expoModules.txt
  1. Run node prettify-output <filename containing output from logs> or yarn prettify-output.

OSX command:

yarn prettify-output expoModules.txt
  1. Copy results that are written in <output filename from previous commands with .js extension

OSX command:

cat expoModules.js | pbcopy
  1. Paste it into packages/jest-expo/src/expoModules.js or just replace this file with new one.

OSX command:

mv expoModules.js ../../packages/jest-expo/src/preset/
  1. Clean after yourself in jest-expo-mock-generator and submit PR with changes.