This repository showcases mobile test automation for a React Native project using the Detox framework. It also includes unit tests for components in the mobile app, as well as unit tests and test automation for the API.
- Mobile Test Automation - Detox - Smoke Tests
- Mobile Test Automation - Detox - Other Tests
- Page Object Modal for Mobile Tests - machineStateTab
- Page Object Modal for Mobile Tests - logPartTab
- Unit Tests for Components - Jest
- Unit Tests for the API - Jest
- API Test Automation - Axios Request
- Detox Artifacts
- Jest Test Coverage from Unit Tests - Mobile App
- Jest Test Coverage from Unit Tests - API
- Mobile Components/UI Snapshots
- Coding Test Challenge
In this repository, you will find a comprehensive set of tests for a React Native project. The tests cover both the mobile app and the API, ensuring the quality and reliability of the software.
The mobile test automation is implemented using the Detox framework. Detox provides a powerful and efficient way to write end-to-end tests in either JavaScript or TypeScript for React Native applications in order to run tests for both iOS and Android with the same code. The tests simulate user interactions and verify the expected behavior of the app.
To run the mobile test automation, follow these steps:
Make sure you have nvm installed.
- Clone the repository:
git clone https://github.com/WarleyLopes/QAEngineeringChallenge2
- In a new terminal window, navigate to
./backend/
- Run
nvm install
- Install the dependencies for the API with
yarn install
- Start the API server with:
yarn start
- In a new terminal window, navigate to
./native-app/
- Run
nvm install
- Install dependencies:
yarn install
- Run the build for iOS with:
yarn detox:build:ios
- Run the tests for iOS with:
yarn detox:test:ios
- For Android, make sure you have an android emulator in Android Studio named as
Pixel_3a_API_31_x86_64
- Make sure the android emulator is created with the API_31 and x86_64 architecture
- Run the build for Android with:
yarn detox:build:android
- Run the tests for Android with:
yarn detox:test:android
Artifacts for the run will be generated in case of any failing tests inside the artifacts folder.
These tests ensure that individual components of the app function correctly and meet the expected behavior. The unit tests are run using the Jest framework, which provides a simple and efficient way to write and run tests in JavaScript or TypeScript and automatically generate code coverage.
To run the unit tests for the mobile components, follow these steps:
Make sure you have nvm installed. And have node version >= 18 installed and being used through nvm.
- Clone the repository:
git clone https://github.com/WarleyLopes/QAEngineeringChallenge2
- Navigate to
./native-app/
- Install dependencies:
yarn install
- Run the tests with:
yarn test
In this section, you will find unit tests for the API and Test Automation using actual requests. These tests ensure that the API functions correctly and returns the expected results. The unit tests and the requests are also run using the Jest framework.
To run the tests for the API, follow these steps:
Make sure you have nvm installed. And have node version >= 18 installed and being used through nvm.
- Clone the repository:
git clone https://github.com/WarleyLopes/QAEngineeringChallenge2
- Navigate to
./backend/
- Install dependencies:
yarn install
- Run the server with:
yarn start
- In a separated termina, run the tests with:
yarn test
For both ./backend/
and ./native-app/
I also took the extra step of adding a pre-commit hook to run prettier, eslint, and jest automatically on before being able to complete a commit. This allows an automatic forced run of those in order to makee sure the coode is formatted according to the defined rules of the project, eslint will enforce code quality and style guidelines according to configurations too, and jest will run the unit tests. This ensures that the codebase remains consistent, maintainable, and free of common errors as long as the tests are comprehensive and extent enough.