Skip to content

Latest commit

 

History

History
68 lines (48 loc) · 1.82 KB

APIRef.Expect.md

File metadata and controls

68 lines (48 loc) · 1.82 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');

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');