Skip to content

Latest commit

 

History

History
78 lines (55 loc) · 2.22 KB

APIRef.Expect.md

File metadata and controls

78 lines (55 loc) · 2.22 KB

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.

Expect verifies if a certain value is as expected to be.

Methods

toBeVisible()

Expect the view to be at least 75% visible.

await expect(element(by.id('UniqueId204'))).toBeVisible();

toBeNotVisible()

Expect the view to not be visible.

await expect(element(by.id('UniqueId205'))).toBeNotVisible();

toExist()

Expect the view to exist in the UI hierarchy.

await expect(element(by.id('UniqueId205'))).toExist();

toNotExist()

Expect the view to not exist in the UI hierarchy.

await expect(element(by.id('RandomJunk959'))).toNotExist();

toHaveText(text)

  • 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.

await expect(element(by.id('UniqueId204'))).toHaveText('I contain some text');

toHaveLabel(label)

  • It searches by accessibilityLabel on iOS, or by contentDescription on Android.

  • In React Native it can be set for both platforms by defining an accessibilityLabel on the view.

await expect(element(by.id('UniqueId204'))).toHaveLabel('Done');

toHaveId(id)

  • In React Native apps, expect UI component to have testID with that id.
  • In native iOS apps, expect UI element to have accesibilityIdentifier with that id.
await expect(element(by.text('I contain some text'))).toHaveId('UniqueId204');

toHaveValue(value)

Expect components like a Switch to have a value ('0' for off, '1' for on).

await expect(element(by.id('UniqueId533'))).toHaveValue('0');