You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/articles/how-detox-works.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -6,11 +6,11 @@ When a Detox test executes, you actually have two different parts running side b
6
6
7
7
-**The mobile app itself**, usually running on a simulator/emulator. A regular native build of your app is installed and executed on the device. Your app is usually built once before the tests start running.
8
8
9
-
-**The test suite**, running on Node.js, ove ra test runner like Jest. The tests are normally written in JavaScript. Because the tests are asynchronous in nature (every test line requires to access the app and wait for a response), the tests rely heavily on [`async`-`await`](https://ponyfoo.com/articles/understanding-javascript-async-await).
9
+
-**The test suite**, running on Node.js, over a test runner like Jest. The tests are normally written in JavaScript. Because the tests are asynchronous in nature (every test line requires to access the app and wait for a response), the tests rely heavily on [`async`-`await`](https://ponyfoo.com/articles/understanding-javascript-async-await).
10
10
11
11
The two parts are usually running in separate processes on your machine. It is also possible to run the two parts on different machines. Communication between the two parts takes place over the network using a web socket.
12
12
13
-
In practice, to make the communication more resilient, both parts are implemented as clients and communicate through a Detox server that acts as mediator. Haivng that server allows for some advantages like allowing one side to disconnect (during a simulator boot for example or app restart) without disconnecting the other side and losing its state.
13
+
In practice, to make the communication more resilient, both parts are implemented as clients and communicate through a Detox server that acts as mediator. Having that server allows for some advantages like allowing one side to disconnect (during a simulator boot for example or app restart) without disconnecting the other side and losing its state.
14
14
15
15
## How Detox Automatically Synchronizes With Your App
Traditionally, one of the most difficult aspects of E2E testing is synchronizing the test scenario with the app. Complex operations inside the app (like accessing servers or performing animations) often take a variable amount of time to complete; In each step, we can’t move on to the next one until they’ve completed (i.e. when the app goes idle), which in turn surfaces a challenge in continously trying to understand when the right time to do so is.
5
+
Traditionally, one of the most difficult aspects of E2E testing is synchronizing the test scenario with the app. Complex operations inside the app (like accessing servers or performing animations) often take a variable amount of time to complete; In each step, we can’t move on to the next one until they’ve completed (i.e. when the app goes idle), which in turn surfaces a challenge in continuously trying to understand when the right time to do so is.
6
6
7
7
Fortunately, Detox - which comes with a gray-box approach, cleverly performs the synchronization automatically, as explained [here](../articles/how-detox-works.md#how-detox-automatically-synchronizes-with-your-app).
8
8
9
-
## Mitigating Synthronization Issues
9
+
## Mitigating Synchronization Issues
10
10
11
11
While Detox's auto-synchronization mechanism is powerful and efficient, it does come with at least one caveat: **It imposes strictness over the app's behavior.** By default, Detox will fail your tests (i.e. due to a wait-for-idle **time-out**), if, for example, following an app launch or a navigation to a new screen, timers or animations continue to run endlessly. While this could be considered an advantage (e.g. finding an animation or timer management leakage!), these type of issues may not:
12
12
13
-
1. Be specifially related to the main coverage goal of your test.
13
+
1. Be specifically related to the main coverage goal of your test.
14
14
2. Be directly visible to or considered a significant bug by the end user.
15
15
16
16
Therefore, it may be something some would want to be able to limit or completely opt-out of. With this in mind, let's review the possible ways of mitigation, aimed at either finding and fixing a bug, or allowing for it to be overlooked.
17
17
18
18
### Step 1: Understanding what's blocking your app
19
19
20
-
Detox's syncrhonization debugging mechanism generates output to Detox's log which provides useful synchronizationd debugging information. We recommend that you'd start by pinpointing what the busy resources are - those that are keeping you app from going idle, based on those logs. Turn the debugging mechanism toggle on if you need to (although, it is on by default), rerun your test(s) and follow Detox's logs.
20
+
Detox's synchronization debugging mechanism generates output to Detox's log which provides useful synchronization debugging information. We recommend that you'd start by pinpointing what the busy resources are - those that are keeping your app from going idle, based on those logs. Turn the debugging mechanism toggle on if you need to (although, it is on by default), rerun your test(s) and follow Detox's logs.
21
21
22
22
:::info
23
23
@@ -54,7 +54,7 @@ await device.launchApp({
54
54
55
55
### Step 2: Applying the Most Suitable Solution
56
56
57
-
First and foremost, as explained, an app's inability to go idle might be an indication of that some resources are _unnecessarily_ busy. Thefeore, whether it's a network request that's been left unacknowledged, or an endless loader -
57
+
First and foremost, as explained, an app's inability to go idle might be an indication of that some resources are _unnecessarily_ busy. Therefore, whether it's a network request that's been left unacknowledged, or an endless loader -
58
58
59
59
**The best solution is to fix the problem!:construction_worker:**
60
60
@@ -64,7 +64,7 @@ Sometimes the resource that's holding the app back from turning idle is a mere a
64
64
65
65

66
66
67
-
The syncrhonization logs telling you that, would usually look roughly like this:
67
+
The synchronization logs telling you that, would usually look roughly like this:
68
68
69
69
```
70
70
09:04:20.170 detox[90417] i The app is busy with the following tasks:
@@ -85,11 +85,11 @@ The syncrhonization logs telling you that, would usually look roughly like this:
85
85
86
86
<sup>(these are logs generated by Detox iOS; Detox-Android generates different yet equivalent ones)</sup>
87
87
88
-
**Below are a few actual-bug scanerios where this can take place - all of which are easy to inspect, identify and fix.**
88
+
**Below are a few actual-bug scenarios where this can take place - all of which are easy to inspect, identify and fix.**
89
89
90
-
##### i. A server is being nonresponsive
90
+
##### i. A server is being non-responsive
91
91
92
-
Your app is waiting indefinitely to load all of the necessary data from the a nonresponsive server / a bad network, and therefore cannot switch to rendering the expected UI. When this is the deal, additional synchronization logs also repeatedly show some in-flight network calls:
92
+
Your app is waiting indefinitely to load all of the necessary data from the a non-responsive server / a bad network, and therefore cannot switch to rendering the expected UI. When this is the deal, additional synchronization logs also repeatedly show some in-flight network calls:
93
93
94
94
```
95
95
09:04:20.170 detox[90417] i The app is busy with the following tasks:
@@ -98,7 +98,7 @@ Your app is waiting indefinitely to load all of the necessary data from the a no
98
98
- URL #2: https://unreachable-server.org/hello
99
99
```
100
100
101
-
_This can be solved by finding out why the server is being nonresponsive or unreachable, for example - by tracking network calls into the logs, or inspecting requests on the server-ends._
101
+
_This can be solved by finding out why the server is being non-responsive or unreachable, for example - by tracking network calls into the logs, or inspecting requests on the server-ends._
102
102
103
103
##### ii. A returned server error is not conveyed by the UI
104
104
@@ -122,14 +122,14 @@ Detox currently has no API's for "black listing" animations - namely, excluding
122
122
123
123
**Not all synchronization issues around animations are trivial:**
124
124
125
-
* The animation can be associated with an element that is rendered off-screen, such as an item in a long news feed that's been rendered beyond the screen's bound, or a loader in a screen associated with a bottom tab that hasn't been naviagated-to since the beginning of the test.
126
-
* The animation can also be associated with elements which have been silently leaked (bug) under other UI elements. They are fully functional yet not visibile to the user. For example: A compact loader accidently showing under the app bar (android)/navigation bar (iOS).
125
+
* The animation can be associated with an element that is rendered off-screen, such as an item in a long news feed that's been rendered beyond the screen's bound, or a loader in a screen associated with a bottom tab that hasn't been navigated-to since the beginning of the test.
126
+
* The animation can also be associated with elements which have been silently leaked (bug) under other UI elements. They are fully functional yet not visible to the user. For example: A compact loader accidentally showing under the app bar (android)/navigation bar (iOS).
127
127
128
128
These types of animations can be difficult to track down, and sometimes fix.
129
129
130
-
**We are aiming to provide more advanced Detox-complementary tools that would help identify such animations more easily (follow github issue [#4734](https://github.com/wix/Detox/issues/4734)). Until we do, here are some things you can do, roughly, in order:**
130
+
**We are aiming to provide more advanced Detox-complementary tools that would help identify such animations more easily (follow Github issue [#4734](https://github.com/wix/Detox/issues/4734)). Until we do, here are some things you can do, roughly, in order:**
131
131
132
-
1._(Most recommended) Start Detox in [debug mode](../introduction/debugging.mdx), and then run the blocked test step-by-step - either from the beginning of it, or starting a breakpoint you've set over where you think the synchronization issue starts. Step over the Detox commands until Detox gets blocked and signals for syncrhonization issues (i.e. in the logs). Then, explore the app yourself (!), physically looking for animations (e.g. by scrolling lists, navigating through tabs, and so on.
132
+
1._(Most recommended) Start Detox in [debug mode](../introduction/debugging.mdx), and then run the blocked test step-by-step - either from the beginning of it, or starting a breakpoint you've set over where you think the synchronization issue starts. Step over the Detox commands until Detox gets blocked and signals for synchronization issues (i.e. in the logs). Then, explore the app yourself (!), physically looking for animations (e.g. by scrolling lists, navigating through tabs, and so on.
133
133
You might actually be able to see the animation in your own eyes, or witness Detox getting unblocked as your interactions release an otherwise endless loader._
134
134
_Do this iteratively until the exact animating UI element can be pinpointed._
135
135
@@ -170,7 +170,7 @@ By default, Detox is designed to ignore JavaScript's `setInterval()` and will on
170
170
171
171
If you can't find the source of the problem, or otherwise decide not to fix it (temporarily...), Detox always has the fail-safe solution of turning off automatic-synchronization altogether and waiting manually for elements.
172
172
173
-
This isn’t the recommended approach as you'd be giving up Detox's syncrhonization super-powers and resort to manually defining timeouts, but hey, life is about tradeoffs. You can do this with the main [syncrhonization switching API's](../api/device.md#devicedisablesynchronization):
173
+
This isn’t the recommended approach as you'd be giving up Detox's synchronization super-powers and resort to manually defining timeouts, but hey, life is about tradeoffs. You can do this with the main [synchronization switching API's](../api/device.md#devicedisablesynchronization):
0 commit comments