This README provides an overview of the testing setup and execution process using Detox for end-to-end (E2E) testing and Jest for unit testing.
- Node.js and npm installed
- Android Studio (for Android testing) or Xcode (for iOS testing) installed
- React Native project set up and running
- Clone the repository:
git clone https://github.com/Blockchain-Powered-eSIM/eSIM-Wallet
- Navigate to the project directory:
cd eSIM-Wallet
- Install dependencies:
npm install
- Detox configuration: Configure Detox in the
.detoxrc.js
file to specify test runner arguments, app configurations, device types, etc. - Jest configuration: Configure Jest in the
e2e/jest.config.js
andbase.jest.config.js
files for unit and E2E testing settings.
Make sure to run the app before running test because because of different emulator settings
- Make sure you choose one of the available emulators: Pixel6_Pro_API_34
- Run unit tests using Jest:
npm test
-
Build the app for testing:
npm run build
-
Start the Detox test environment:
npm run test
> eSIM-Wallet@0.0.1 test
> detox test --configuration android.emu.debug
18:43:10.127 detox[19993] B jest --config e2e/jest.config.js
18:43:13.241 detox[19996] i firstTest.spec.js is assigned to emulator-5554 (Pixel_6_Pro_API_34)
18:43:13.243 detox[19996] i App Launch Test: should launch the app successfully
18:43:16.563 detox[19996] i App Launch Test: should launch the app successfully [OK]
18:43:16.565 detox[19996] i Modal Visibility Test: should initially hide the modal
18:43:16.700 detox[19996] i Modal Visibility Test: should initially hide the modal [OK]
18:43:16.701 detox[19996] i Unique ID Fetch Test: should fetch and display unique ID in modal
18:43:18.248 detox[19996] i Unique ID Fetch Test: should fetch and display unique ID in modal [OK]
18:43:18.249 detox[19996] i Modal Dismissal Test: should dismiss the modal when "Back" button is pressed
18:43:19.910 detox[19996] i Modal Dismissal Test: should dismiss the modal when "Back" button is pressed [OK]
18:43:19.911 detox[19996] i Generate EC KeyPair Test: should generate and display EC KeyPair
18:43:23.324 detox[19996] i Generate EC KeyPair Test: should generate and display EC KeyPair [OK]
PASS e2e/firstTest.spec.js (12.573 s)
App Launch Test
✓ should launch the app successfully (3320 ms)
Modal Visibility Test
✓ should initially hide the modal (134 ms)
Unique ID Fetch Test
✓ should fetch and display unique ID in modal (1547 ms)
Modal Dismissal Test
✓ should dismiss the modal when "Back" button is pressed (1661 ms)
Generate EC KeyPair Test
✓ should generate and display EC KeyPair (3412 ms)
Test Suites: 1 passed, 1 total
Tests: 5 passed, 5 total
Snapshots: 0 total
Time: 12.639 s, estimated 64 s
Ran all test suites.
- If tests fail, review the error messages and logs provided by Jest and Detox for insights into the cause of the failure.
- Check for issues related to emulator/device setup, app launch, test environment configuration, etc.
- If the emulator or device does not respond or encounters errors, try restarting it.
- Ensure that the emulator/device is properly configured and has the necessary permissions and resources allocated.
- Double-check the configuration settings in
.detoxrc.js
ande2e/jest.config.js
for correctness and compatibility with your testing environment.
- Detox Documentation: Official Detox documentation for detailed usage instructions and troubleshooting tips.
- Jest Documentation: Official Jest documentation for comprehensive guides and API references.
- React Native Documentation: Official React Native documentation for learning and reference.
When attempting to wipe the data and restart an Android Virtual Device (AVD) emulator, the error message "PANIC: Unknown AVD name [avd_name]" is encountered. This error indicates that the specified AVD name is not recognized or does not exist.
PANIC: Unknown AVD name [avd_name], use -list-avds to see valid list.
HOME is defined but there is no file avd_name.ini in $HOME/.android/avd
(Note: Directories are searched in the order $ANDROID_AVD_HOME, $ANDROID_SDK_HOME/avd, and $HOME/.android/avd)
- Incorrect AVD name specified.
- AVD not created or configured properly.
- Emulator or AVD Manager misconfiguration.
-
List Available AVDs: Open Terminal or Command Prompt and navigate to your Android SDK tools directory. Run the following command to list the available AVDs: emulator -list-avds
-
Identify AVD Name: Look for the name of the emulator you want to wipe in the list that's displayed.
-
Run AVD Manager Command: Once you've identified the correct AVD name, run the AVD Manager command with the correct AVD name to wipe its data:
emulator -avd your_avd_name -wipe-data
Replaceyour_avd_name
with the name of the AVD you want to wipe. -
Wait for Emulator to Restart: The emulator will restart with wiped data. Wait for it to finish booting up.
-
Retry Tests: Once the emulator is up and running again, retry running your Detox tests to see if the issue is resolved.