Skip to content

Testing Local Storage Calls

Ramy Zhang edited this page Jan 29, 2023 · 5 revisions

So you've got your local storage call to RNFS all set up in LessonPlanService.js, but want to test if it actually works or not. The ideal way to do this would be by using Jest, but for now here's 2 alternative ways to test.

Method 1

iOS

While you have your iPhone simulator instance running, you can peek into the device's internal storage by opening a new terminal tab and ls-ing into its storage, typically at the following path: ~/Library/Developer/CoreSimulator/Devices/[DEVICE ID]/data/Containers/Data/Application/[APP ID]/Documents Get the Device ID by going into Xcode: Window -> Devices and Simulators -> Simulators. The Identifier value is the device ID.

Alternatively, you can also add a breakpoint in Xcode and perform the action po NSHomeDirectory() upon break.

Android

Check the internal storage in Android Studio via the following method. You'll specifically want to go into data/data/sistema/ to check app data, which you are writing and reading.

Method 2

  1. Import Local (or just an individual function) into App.js
  2. Call your functions inside MainNavigator, make sure the console.logs return something valuable
  3. Check outputs in the Metro server Terminal window!

Using readDirectory() from Local.js is a fast way of making sure your files are all there in your directory, so you can use that a lot to view your internal storage details! For example; here's how I tested Local.js in App.js!

Screenshot 2023-01-29 at 8 24 20 AM Screenshot 2023-01-29 at 8 21 15 AM Screenshot 2023-01-29 at 8 21 29 AM
Clone this wiki locally