Skip to content

Commit c5c0b46

Browse files
authored
Merge pull request #241 from flexbox/feat/maestro
feat: 🎸 add bonus section with maestro
2 parents 6df6352 + 0bb86dd commit c5c0b46

File tree

4 files changed

+92
-1
lines changed

4 files changed

+92
-1
lines changed

challenges/ecosystem/05.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,3 +215,8 @@ Now you can run `npm run test:watch` to watch your files and run tests automatic
215215

216216
- https://reactnativetesting.io/
217217
- https://github.com/vanGalilea/react-native-testing?tab=readme-ov-file#covered-examples-
218+
219+
220+
### 👽 Bonus
221+
222+
- [ ] Check the [React Native Testing Library Cookbook](https://callstack.github.io/react-native-testing-library/cookbook/index) and add a new test to your component.

challenges/ecosystem/06.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Exercise 6: End-to-End Testing with Maestro
2+
3+
## 📡 What you will learn
4+
5+
- Set up end-to-end (E2E) tests for your React Native application.
6+
- Use Maestro to write and run automated E2E tests.
7+
8+
## 👾 Before we start the exercise
9+
10+
End-to-end (E2E) testing involves testing the complete functionality of an application from the user's perspective, ensuring all components work together as expected.
11+
12+
Maestro is a powerful library for automating user interactions in your React Native app, allowing you to write and run E2E tests.
13+
14+
- Check the [Maestro documentation](https://maestro.mobile.dev/getting-started/installing-maestro).
15+
16+
## 👨‍🚀 Exercise 6
17+
18+
### Setting Up Maestro
19+
20+
1. **Install Maestro**:
21+
Follow the [getting started guide](https://maestro.mobile.dev/getting-started/installing-maestro) to install Maestro on your laptop.
22+
23+
### Writing Your First Test
24+
25+
1. **Create a Tests Folder**:
26+
- [ ] At the root of your project, create a `tests` folder.
27+
28+
2. **Create a Test File**:
29+
- [ ] Create a file named `process.yaml` in the `tests` folder.
30+
31+
3. **Add Maestro Script**:
32+
- [ ] Add the following script to your `package.json`:
33+
34+
```json
35+
"scripts": {
36+
"maestro": "maestro test tests/process.yaml"
37+
}
38+
39+
4. **Write Your Test**:
40+
- [ ] Write a test in the `process.yaml` file.
41+
42+
You should have something like this:
43+
44+
```yaml
45+
appId: host.exp.Exponent
46+
---
47+
48+
- launchApp
49+
- tapOn: "Email"
50+
- inputText: "[email protected]"
51+
- tapOn: "Password"
52+
- inputText: "123456"
53+
- tapOn: "Login"
54+
- waitFor: "Welcome"
55+
- tapOn: "Buy this ship"
56+
- tapOn: "Confirm"
57+
```
58+
59+
### Running Your Test
60+
61+
1. **Run Your Test**:
62+
- [ ] Run your test by lanching your project on a simulator and executing the following command:
63+
64+
```console
65+
npm run maestro
66+
```
67+
68+
2. **Check the Results**:
69+
You should see the test running on your simulator.
70+
71+
### 👽 Bonus
72+
73+
- [ ] Write more tests for your application.
74+
- [ ] Explore Maestro's documentation to learn more about its capabilities.
75+
- [ ] Write a more complex test that involves testIDs.

hackathon/spacecraft/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"web": "expo start --web",
99
"eject": "expo eject",
1010
"lint": "eslint --ignore-path .gitignore --ext .js,.ts,.tsx .",
11+
"maestro": "maestro test tests/process.yaml",
1112
"test": "jest",
1213
"test:watch": "jest --watch",
1314
"build-storybook": "build-storybook",
@@ -103,4 +104,4 @@
103104
"prettier": "^3.2.5",
104105
"typescript": "~5.3.3"
105106
}
106-
}
107+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
appId: host.exp.Exponent
2+
---
3+
4+
- tapOn: "Email"
5+
- inputText: "[email protected]"
6+
- tapOn: "Password"
7+
- inputText: "123456"
8+
- tapOn: "Login"
9+
- tapOn: "Buy this ship"
10+
- tapOn: "Ok"

0 commit comments

Comments
 (0)