Skip to content

Commit

Permalink
Make Docs Great Again
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoNatan committed Jun 24, 2019
1 parent 196c566 commit 7f8b563
Show file tree
Hide file tree
Showing 36 changed files with 110 additions and 312 deletions.
40 changes: 19 additions & 21 deletions docs/APIRef.ActionsOnElement.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
---
id: APIRef.ActionsOnElement
title: Actions on Element
---
# Actions on Element

Detox uses **Matchers** to find UI `elements` in your app, **Actions** to emulate user interaction with those `elements` and **Expectations** to verify values on those `elements`.

Expand Down Expand Up @@ -36,8 +33,8 @@ await element(by.id('tappable')).tap();
```

### `longPress(duration)`
Simulate long press on an element.<br>
duration - long press time interval. (iOS only)<br>
Simulate long press on an element.
duration - long press time interval. (iOS only)

```js
await element(by.id('tappable')).longPress();
Expand All @@ -50,7 +47,8 @@ Simulate multiple taps on an element.
await element(by.id('tappable')).multiTap(3);
```
### `tapAtPoint()`
Simulate tap at a specific point on an element.<br><br>
Simulate tap at a specific point on an element.

Note: The point coordinates are relative to the matched element and the element size could changes on different devices or even when changing the device font size.

```js
Expand Down Expand Up @@ -102,11 +100,11 @@ await element(by.id('textField')).clearText();

### `scroll(pixels, direction, startPositionX=NaN, startPositionY=NaN)`

Scroll amount of pixels.<br>
pixels - independent device pixels<br>
direction - left/right/top/bottom<br>
startPositionX - The X starting scroll position, in percentage; valid input: (0.0, 1.0), `NaN`; default: `NaN`—Choose the best value<br>
startPositionY - The Y starting scroll position, in percentage; valid input: (0.0, 1.0), `NaN`; default: `NaN`—Choose the best value<br>
Scroll amount of pixels.
pixels - independent device pixels
direction - left/right/top/bottom
startPositionX - The X starting scroll position, in percentage; valid input: (0.0, 1.0), `NaN`; default: `NaN`—Choose the best value
startPositionY - The Y starting scroll position, in percentage; valid input: (0.0, 1.0), `NaN`; default: `NaN`—Choose the best value

```js
await element(by.id('scrollView')).scroll(100, 'down', NaN, 0.85);
Expand All @@ -126,8 +124,8 @@ await element(by.id('scrollView')).scrollTo('top');

### `swipe(direction, speed, percentage)`

direction - left/right/up/down<br>
speed - fast/slow - default is fast<br>
direction - left/right/up/down
speed - fast/slow - default is fast
percentage - (optional) screen percentage to swipe as float

```js
Expand All @@ -137,8 +135,8 @@ await element(by.id('scrollView')).swipe('down', 'fast', 0.5);
```
### `setColumnToValue(column, value)` iOS only

column - date picker column index<br>
value - string value to set in column<br>
column - date picker column index
value - string value to set in column

```js
await expect(element(by.type('UIPickerView'))).toBeVisible();
Expand All @@ -148,9 +146,9 @@ await element(by.type('UIPickerView')).setColumnToValue(2,"34");

### `pinchWithAngle(direction, speed, angle)` iOS only

direction - inward/outward<br>
speed - slow/fast - default is slow<br>
angle - value in radiant - default is 0<br>
direction - inward/outward
speed - slow/fast - default is slow
angle - value in radiant - default is 0

```js
await expect(element(by.id('PinchableScrollView'))).toBeVisible();
Expand All @@ -159,8 +157,8 @@ await element(by.id('PinchableScrollView')).pinchWithAngle('outward', 'slow', 0)

### `setDatePickerDate(dateString, dateFormat)` iOS only

dateString - string representing a date in the supplied dateFormat<br>
dateFormat - format for the dateString supplied<br>
dateString - string representing a date in the supplied dateFormat
dateFormat - format for the dateString supplied

```js
await expect(element(by.type('UIDatePicker'))).toBeVisible();
Expand Down
5 changes: 1 addition & 4 deletions docs/APIRef.Artifacts.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
---
id: APIRef.Artifacts
title: Artifacts
---
# Artifacts

Artifacts are various recordings during tests including, but not limited to, device logs, device screenshots and screen recordings (videos).

Expand Down
9 changes: 3 additions & 6 deletions docs/APIRef.Configuration.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
---
id: APIRef.Configuration
title: Configuration Options
---
# Configuration Options

## Configuring package.json

### Device Configuration

`configurations` holds all the device configurations, if there is only one configuration in `configurations` `detox build` and `detox test` will default to it, to choose a specific configuration use `--configuration` param<br>
`configurations` holds all the device configurations, if there is only one configuration in `configurations` `detox build` and `detox test` will default to it, to choose a specific configuration use `--configuration` param

|Configuration Params|Details|
|---|---|
|`type`| Device type, available options are `ios.simulator`, `ios.none`, `android.emulator`, and `android.attached`. |
|`binaryPath`| Relative path to the ipa/app due to be tested (make sure you build the app in a project relative path)|
|`testBinaryPath`| (optional, Android only): relative path to the test app (apk) |
|`name`| Device name, aligns to the device list avaliable through `xcrun simctl list` for example, this is one line of the output of `xcrun simctl list`: `A3C93900-6D17-4830-8FBE-E102E4BBCBB9 iPhone 7 Shutdown iPhone 7 iOS 10.2`, in order to choose the first `iPhone 7` regardless of OS version, use `iPhone 7`. <br>To be OS specific use `iPhone 7, iOS 10.2`|
|`name`| Device name, aligns to the device list avaliable through `xcrun simctl list` for example, this is one line of the output of `xcrun simctl list`: `A3C93900-6D17-4830-8FBE-E102E4BBCBB9 iPhone 7 Shutdown iPhone 7 iOS 10.2`, in order to choose the first `iPhone 7` regardless of OS version, use `iPhone 7`. To be OS specific use `iPhone 7, iOS 10.2`|
|`build`| **[optional]** Build command (either `xcodebuild`, `react-native run-ios`, etc...), will be later available through detox CLI tool.|

**Example:**
Expand Down
5 changes: 1 addition & 4 deletions docs/APIRef.DetoxCLI.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
---
id: APIRef.DetoxCLI
title: Detox Command Line Tools (detox-cli)
---
# Detox Command Line Tools (detox-cli)

`detox-cli` lets you operate Detox from command line.

Expand Down
5 changes: 1 addition & 4 deletions docs/APIRef.DetoxObjectAPI.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
---
id: APIRef.DetoxObjectAPI
title: The `detox` Object
---
# The `detox` Object

`detox` is globally available in every test file, though currently it is only used in the setup/init file.

Expand Down
25 changes: 11 additions & 14 deletions docs/APIRef.DeviceObjectAPI.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
---
id: APIRef.DeviceObjectAPI
title: The `device` Object
---
# The `device` Object

`device` is globally available in every test file, it enables control over the current attached device (currently only simulators are supported).

Expand Down Expand Up @@ -200,7 +197,7 @@ await device.launchApp({
```

### `device.relaunchApp(params)`
**Deprecated** Use `device.launchApp(params)` instead. This method is now calling `launchApp({newInstance: true})` for backwards compatibility.<Br>
**Deprecated** Use `device.launchApp(params)` instead. This method is now calling `launchApp({newInstance: true})` for backwards compatibility.
Kill and relaunch the app defined in the current [`configuration`](APIRef.Configuration.md).

### `device.terminateApp()`
Expand All @@ -213,8 +210,8 @@ await device.terminateApp('other.bundle.id');
```

### `device.sendToHome()`
Send application to background by bringing `com.apple.springboard` to the foreground.<br>
Combining `sendToHome()` with `launchApp({newInstance: false})` will simulate app coming back from background.<br>
Send application to background by bringing `com.apple.springboard` to the foreground.
Combining `sendToHome()` with `launchApp({newInstance: false})` will simulate app coming back from background.
Check out Detox's [own test suite](../detox/test/e2e/06.device.test.js)

```js
Expand Down Expand Up @@ -248,23 +245,23 @@ await device.installApp('other.bundle.id');
```

### `device.openURL({url, sourceApp[optional]})`
Mock opening the app from URL. `sourceApp` is an optional parameter to specify source application bundle id.<br>
Read more in [Mocking Open From URL](APIRef.MockingOpenFromURL.md) section.<br>
Mock opening the app from URL. `sourceApp` is an optional parameter to specify source application bundle id.
Read more in [Mocking Open From URL](APIRef.MockingOpenFromURL.md) section.
Check out Detox's [own test suite](../detox/test/e2e/15.urls.test.js)

### `device.sendUserNotification(params)`
Mock handling of received user notification when app is in foreground.<br>
Read more in [Mocking User Notifications](APIRef.MockingUserNotifications.md) section.<br>
Mock handling of received user notification when app is in foreground.
Read more in [Mocking User Notifications](APIRef.MockingUserNotifications.md) section.
Check out Detox's [own test suite](../detox/test/e2e/11.user-notifications.test.js)

### `device.sendUserActivity(params)`
Mock handling of received user activity when app is in foreground.<br>
Read more in [Mocking User Activity](APIRef.MockingUserActivity.md) section.<br>
Mock handling of received user activity when app is in foreground.
Read more in [Mocking User Activity](APIRef.MockingUserActivity.md) section.
Check out Detox's [own test suite](../detox/test/e2e/18.user-activities.test.js)

### `device.setOrientation(orientation)`
Takes `"portrait"` or `"landscape"` and rotates the device to the given orientation.
Currently only available in the iOS Simulator.<br>
Currently only available in the iOS Simulator.
Check out Detox's [own test suite](../detox/test/e2e/06.device-orientation.test.js)

### `device.setLocation(lat, lon)`
Expand Down
5 changes: 1 addition & 4 deletions docs/APIRef.Expect.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
---
id: APIRef.Expect
title: Expect
---
# Expect

Detox uses **Matchers** to find UI `elements` in your app, **Actions** to emulate user interaction with those `elements` and **Expectations** to verify values on those `elements`.

Expand Down
7 changes: 2 additions & 5 deletions docs/APIRef.Matchers.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
---
id: APIRef.Matchers
title: Matchers
---
# Matchers

Detox uses **Matchers** to find UI `elements` in your app, **Actions** to emulate user interaction with those `elements` and **Expectations** to verify values on those `elements`.

Expand Down Expand Up @@ -119,7 +116,7 @@ element(by.id('parent').withDescendant(by.id('child')));
When a matcher matches multiple views, there are three possible solutions:

1. Use multiple matchers to narrow down the matched results.
2. Add unique identifiers (testIDs) to the view which need to matched.<br>
2. Add unique identifiers (testIDs) to the view which need to matched.
A common use-case, is adding identifiers to list items. testIDs for FlatList items can be assigned dynamically, by passing `index` in [`renderItem({item, index})`](https://facebook.github.io/react-native/docs/flatlist.html#renderitem) and using it in the component's render function.

FlatList `renderItem` function:
Expand Down
5 changes: 1 addition & 4 deletions docs/APIRef.MockingOpenFromURL.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
---
id: APIRef.MockingOpenFromURL
title: Mocking Open from URL (Deep Links)
---
# Mocking Open from URL (Deep Links)

You can mock opening the app from URL to test your app's deep link handling mechanism.

Expand Down
5 changes: 1 addition & 4 deletions docs/APIRef.MockingUserActivity.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
---
id: APIRef.MockingUserActivity
title: Mocking User Activity
---
# Mocking User Activity

Detox supports mocking user activity for iOS apps.

Expand Down
5 changes: 1 addition & 4 deletions docs/APIRef.MockingUserNotifications.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
---
id: APIRef.MockingUserNotifications
title: Mocking User Notifications
---
# Mocking User Notifications

Detox supports mocking user notifications for iOS apps.

Expand Down
5 changes: 1 addition & 4 deletions docs/APIRef.TestLifecycle.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
---
id: APIRef.TestLifecycle
title: Test Lifecycle
---
# Test Lifecycle

Detox is test runner independent, and we encourage you to choose your own test runner, but for the sake of demonstration we will use `mocha`'s syntax.

Expand Down
19 changes: 8 additions & 11 deletions docs/APIRef.waitFor.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
---
id: APIRef.waitFor
title: Manual Synchronization Using `waitFor`
---
# Manual Synchronization Using `waitFor`

In most cases, tests should be automatically synchronized with the app. When synchronization doesn't work, you have a fail-safe by using `waitFor`. This API polls using the given expectation continuously until the expectation is met. Use manual synchronization with `waitFor` only as a **last resort**. Polling for expectations isn't exactly a best practice.

Test async code with waitFor.<br>
Test async code with waitFor.
**Hang the test until an expectation is met.**

### Methods
Expand All @@ -24,7 +21,7 @@ Test async code with waitFor.<br>
>NOTE: `waitFor` will not throw when reaching timeout, instead it will just continue to the next line. To make sure your tests work as you expect them to add `expect()` at the following line.
### `toBeVisible()`
Test will hang until expectation is met or a timeout has occurred. Should be accompanied with [`expect.toBeVisible()`](APIRef.Expect.md#tobevisible)<br>
Test will hang until expectation is met or a timeout has occurred. Should be accompanied with [`expect.toBeVisible()`](APIRef.Expect.md#tobevisible)
Wait for the view to be at least 75% visible.

```js
Expand All @@ -33,7 +30,7 @@ await expect(element(by.id('UniqueId204'))).toBeVisible();
```

### `toBeNotVisible()`
Test will hang until expectation is met or a timeout has occurred. Should be accompanied with [`expect.toBeNotVisible()`](APIRef.Expect.md#tobenotvisible)<br>
Test will hang until expectation is met or a timeout has occurred. Should be accompanied with [`expect.toBeNotVisible()`](APIRef.Expect.md#tobenotvisible)
Wait for the view to not be visible.

```js
Expand All @@ -42,7 +39,7 @@ await expect(element(by.id('UniqueId205'))).toBeNotVisible();
```

### `toExist()`
Test will hang until expectation is met or a timeout has occurred. Should be accompanied with [`expect.toExist()`](APIRef.Expect.md#toexist)<br>
Test will hang until expectation is met or a timeout has occurred. Should be accompanied with [`expect.toExist()`](APIRef.Expect.md#toexist)
Wait for the view to exist in the UI hierarchy.

```js
Expand All @@ -51,7 +48,7 @@ await expect(element(by.id('UniqueId205'))).toExist();
```

### `toNotExist()`
Test will hang until expectation is met or a timeout has occurred. Should be accompanied with [`expect.toNotExist()`](APIRef.Expect.md#tonotexist)<br>
Test will hang until expectation is met or a timeout has occurred. Should be accompanied with [`expect.toNotExist()`](APIRef.Expect.md#tonotexist)
Wait for the view to not exist in the UI hierarchy.

```js
Expand All @@ -60,7 +57,7 @@ await expect(element(by.id('RandomJunk959'))).toNotExist();
```

### `toHaveText(text)`
Test will hang until expectation is met or a timeout has occurred. Should be accompanied with [`expect.toHaveText(text)`](APIRef.Expect.md#tohavetexttext)<br>
Test will hang until expectation is met or a timeout has occurred. Should be accompanied with [`expect.toHaveText(text)`](APIRef.Expect.md#tohavetexttext)
- In React Native apps, expect UI component of type `<Text>` to have text.
- In native iOS apps, expect UI elements of type UIButton, UILabel, UITextField or UITextViewIn to have inputText with text.

Expand All @@ -70,7 +67,7 @@ await expect(element(by.id('UniqueId204'))).toHaveText('I contain some text');
```

### `toHaveValue(value)`
Test will hang until expectation is met or a timeout has occurred. Should be accompanied with [`expect.toHaveValue(value)`](APIRef.Expect.md#tohavevaluevalue)<br>
Test will hang until expectation is met or a timeout has occurred. Should be accompanied with [`expect.toHaveValue(value)`](APIRef.Expect.md#tohavevaluevalue)

- In React Native apps, expect UI component to have [`testID`](https://facebook.github.io/react-native/docs/view.html#testid) with that id.
- In native iOS apps, expect UI element to have accesibilityIdentifier with that id.
Expand Down
5 changes: 1 addition & 4 deletions docs/Guide.Contributing.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
---
id: Guide.Contributing
title: Contributing
---
# Contributing

## Prerequisites

Expand Down
5 changes: 1 addition & 4 deletions docs/Guide.DebuggingInXcode.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
---
id: Guide.DebuggingInXcode
title: Debugging in Xcode During Detox Tests
---
# Debugging in Xcode During Detox Tests

> This is mostly useful for investigating weird crashes or when contributing to Detox itself. **This workflow isn't standard. Don't use it unless you have a good reason.**
Expand Down
Loading

0 comments on commit 7f8b563

Please sign in to comment.