E2E Testing with Maestro
1. Document Structure
This document is structured to provide a comprehensive guide on setting up and executing end-to-end (E2E) tests using Maestro in the BACA project. The main sections include:
- Installing Maestro
- Configuration process
- Running tests
- Explanation of YAML files
- Troubleshooting common issues
- Benefits and limitations of the E2E testing approach
- Best practices
This documentation is designed to be understandable and useful for both new and experienced developers, UI/UX designers, testers, and other team members involved in the project. Each section contains detailed information and practical examples to facilitate the implementation and execution of E2E tests within the context of BACA.
2. Configuration and Installation Process
Installing Maestro
To install Maestro, follow these steps:
-
Ensure that Node.js is installed on your system.
-
Open a terminal in the project’s root directory.
-
Run the following command:
yarn install-maestro
This command is a custom npm script that executes:
curl -Ls 'https://get.maestro.mobile.dev' | bash
The script automatically downloads and installs Maestro on your system.
-
Verify the installation by running:
maestro --version
You should see the Maestro version if the installation was successful.
Environment Setup
-
Expo Setup:
-
Project Setup:
-
Ensure that all project dependencies are installed:
yarn install
-
-
Mock Server Configuration:
- Check that the
ENABLED_MOCKED_SERVER
environment variable is correctly configured in the.env
file.
- Check that the
-
Maestro Studio Configuration (optional but recommended):
- Maestro Studio provides a visual interface for creating and debugging E2E tests.
3. Running Tests
Running All Tests
To run all E2E tests for BACA, follow these steps:
-
Start the mock server:
yarn start:e2e
It’s crucial that the mock server is enabled (ENABLED_MOCKED_SERVER) before running the tests.
-
In another terminal, start Maestro Studio for a visual testing experience (optional):
maestro studio
-
In a new terminal, execute all tests using the following command:
yarn test:e2e
Running Individual Tests
To run a single test, use the following command format:
maestro test <path-to-yaml-file> -e APP_ID=host.exp.Exponent --debug-output=./e2e-debug-output
Replace <path-to-yaml-file>
with the specific path to the test you want to run. For example:
- To run the login test:
maestro test .maestro/auth/login-with-validation.yaml -e APP_ID=host.exp.Exponent --debug-output=./e2e-debug-output
- To run the full-screen form test:
maestro test .maestro/home/full-screen-form.yaml -e APP_ID=host.exp.Exponent --debug-output=./e2e-debug-output
Ensure you are in the project’s root directory when executing these commands.