How to use detox - 10 common examples

To help you get started, we’ve selected a few detox examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github flow-typed / flow-typed / definitions / npm / detox_v7.x.x / test_detox_v7.x.x.js View on Github external
}
};

// Detox Object API
// ----------------
detox.cleanup();
// $ExpectError
detox.init({ configurations: "" }, { initGlobals: 123, launchApp: false });
detox.init(configs, { initGlobals: false });

// Device Object API
// -----------------
device.launchApp({});
device.launchApp({ newInstance: true });
device.launchApp({ permissions: { calendar: "YES" } });
device.launchApp({ url: "url", newInstance: false });
device.launchApp({ userNotification: { title: "push" }, newInstance: true });
device.launchApp({ launchArgs: { arg1: 1, arg2: "2" } });
// $ExpectError
device.launchApp({ permissions: false, url: false });

// $ExpectError
device.terminateApp({ err: "err" });
device.terminateApp();
device.terminateApp("other.bundle.id");
device.reloadReactNative();
device.sendToHome();
device.installApp();
device.uninstallApp();
// $ExpectError
device.openURL({ url: "https://flow.org", sourceApp: false });
device.openURL({ url: "https://flow.org" });
github flow-typed / flow-typed / definitions / npm / detox_v7.x.x / test_detox_v7.x.x.js View on Github external
detox.init(configs, { initGlobals: false });

// Device Object API
// -----------------
device.launchApp({});
device.launchApp({ newInstance: true });
device.launchApp({ permissions: { calendar: "YES" } });
device.launchApp({ url: "url", newInstance: false });
device.launchApp({ userNotification: { title: "push" }, newInstance: true });
device.launchApp({ launchArgs: { arg1: 1, arg2: "2" } });
// $ExpectError
device.launchApp({ permissions: false, url: false });

// $ExpectError
device.terminateApp({ err: "err" });
device.terminateApp();
device.terminateApp("other.bundle.id");
device.reloadReactNative();
device.sendToHome();
device.installApp();
device.uninstallApp();
// $ExpectError
device.openURL({ url: "https://flow.org", sourceApp: false });
device.openURL({ url: "https://flow.org" });

// $ExpectError
device.sendUserNotification();
const userNotificationCalendarTrigger = {
  trigger: {
    type: "calendar",
    "date-components": {
      era: 1,
github flow-typed / flow-typed / definitions / npm / detox_v7.x.x / test_detox_v7.x.x.js View on Github external
waitFor(element(by.id("UniqueId204"))).whileElement("someID");
waitFor(element(by.id("UniqueId204"))).whileElement(by.id("ScrollView630"));
// $ExpectError
waitFor(element(by.id("UniqueId204"))).withTimeout(false);
waitFor(element(by.id("UniqueId204"))).withTimeout(1000);

// Example tests
const e2e = {
  NATIVE_BUTTON: "NATIVE_BUTTON",
  WELCOME_VIEW: "WELCOME_VIEW"
};

const welcome = element(by.id(e2e.WELCOME_VIEW));
expect(welcome).toBeVisible();
const welcome_text = "Shake your phone to open the developer menu.";
expect(element(by.text(welcome_text))).toBeVisible();
const btn = element(by.id(e2e.NATIVE_BUTTON));
btn.tap();
github flow-typed / flow-typed / definitions / npm / detox_v7.x.x / test_detox_v7.x.x.js View on Github external
// Expect API
// ----------
expect(element(by.id("UniqueId204"))).toBeVisible();
expect(element(by.id("UniqueId204"))).toBeNotVisible();
expect(element(by.id("UniqueId204"))).toBeVisible();
expect(element(by.id("UniqueId204"))).toExist();
// $ExpectError
expect(element(by.id("UniqueId204"))).toHaveId(123);
expect(element(by.id("UniqueId204"))).toHaveId("someTestID");

// $ExpectError
expect(element(by.id("UniqueId204"))).toHaveLabel();
expect(element(by.id("UniqueId204"))).toHaveLabel("testLabel");

// $ExpectError
expect(element(by.id("UniqueId204"))).toHaveText(123);
expect(element(by.id("UniqueId204"))).toHaveText("some text");
// $ExpectError
expect(element(by.id("UniqueId204"))).toHaveValue(true);
expect(element(by.id("UniqueId204"))).toHaveValue("1");
expect(element(by.id("UniqueId204"))).toNotExist();

// waitFor API
waitFor(element(by.id("UniqueId204"))).toBeNotVisible();
waitFor(element(by.id("UniqueId204"))).toBeNotVisible();
waitFor(element(by.id("UniqueId204"))).toBeVisible();
// $ExpectError
waitFor(element(by.id("UniqueId204")))
  .toExist()
  .something();
waitFor(element(by.id("UniqueId204"))).toExist();
waitFor(element(by.id("UniqueId204"))).toHaveText("text");
github flow-typed / flow-typed / definitions / npm / detox_v7.x.x / test_detox_v7.x.x.js View on Github external
// Device Object API
// -----------------
device.launchApp({});
device.launchApp({ newInstance: true });
device.launchApp({ permissions: { calendar: "YES" } });
device.launchApp({ url: "url", newInstance: false });
device.launchApp({ userNotification: { title: "push" }, newInstance: true });
device.launchApp({ launchArgs: { arg1: 1, arg2: "2" } });
// $ExpectError
device.launchApp({ permissions: false, url: false });

// $ExpectError
device.terminateApp({ err: "err" });
device.terminateApp();
device.terminateApp("other.bundle.id");
device.reloadReactNative();
device.sendToHome();
device.installApp();
device.uninstallApp();
// $ExpectError
device.openURL({ url: "https://flow.org", sourceApp: false });
device.openURL({ url: "https://flow.org" });

// $ExpectError
device.sendUserNotification();
const userNotificationCalendarTrigger = {
  trigger: {
    type: "calendar",
    "date-components": {
      era: 1,
      year: 2017,
      month: 1,
github flow-typed / flow-typed / definitions / npm / detox_v7.x.x / test_detox_v7.x.x.js View on Github external
title: "From push",
  subtitle: "Subtitle",
  body: "Body",
  badge: 1,
  payload: {
    key1: "value1",
    key2: "value2"
  },
  category: "com.example.category",
  "content-available": 0,
  "action-identifier": "default"
};
device.sendUserNotification(userNotificationCalendarTrigger);
device.sendUserNotification(userNotificationLocationTrigger);
device.sendUserNotification(userNotificationTimeIntervalTrigger);
device.sendUserNotification(userNotificationPushTrigger);

// $ExpectError
device.setOrientation("normal");
device.setOrientation("portrait");

// $ExpectError
device.setLocation();
device.setLocation(32.04, 34.78);

device.setURLBlacklist(["https://flow.org", "https://flow.org"]);
device.enableSynchronization();
device.disableSynchronization();
device.resetContentAndSettings();
device.getPlatform();

// Matchers
github flow-typed / flow-typed / definitions / npm / detox_v7.x.x / test_detox_v7.x.x.js View on Github external
},
  title: "From push",
  subtitle: "Subtitle",
  body: "Body",
  badge: 1,
  payload: {
    key1: "value1",
    key2: "value2"
  },
  category: "com.example.category",
  "content-available": 0,
  "action-identifier": "default"
};
device.sendUserNotification(userNotificationCalendarTrigger);
device.sendUserNotification(userNotificationLocationTrigger);
device.sendUserNotification(userNotificationTimeIntervalTrigger);
device.sendUserNotification(userNotificationPushTrigger);

// $ExpectError
device.setOrientation("normal");
device.setOrientation("portrait");

// $ExpectError
device.setLocation();
device.setLocation(32.04, 34.78);

device.setURLBlacklist(["https://flow.org", "https://flow.org"]);
device.enableSynchronization();
device.disableSynchronization();
device.resetContentAndSettings();
device.getPlatform();
github flow-typed / flow-typed / definitions / npm / detox_v7.x.x / test_detox_v7.x.x.js View on Github external
type: "push"
  },
  title: "From push",
  subtitle: "Subtitle",
  body: "Body",
  badge: 1,
  payload: {
    key1: "value1",
    key2: "value2"
  },
  category: "com.example.category",
  "content-available": 0,
  "action-identifier": "default"
};
device.sendUserNotification(userNotificationCalendarTrigger);
device.sendUserNotification(userNotificationLocationTrigger);
device.sendUserNotification(userNotificationTimeIntervalTrigger);
device.sendUserNotification(userNotificationPushTrigger);

// $ExpectError
device.setOrientation("normal");
device.setOrientation("portrait");

// $ExpectError
device.setLocation();
device.setLocation(32.04, 34.78);

device.setURLBlacklist(["https://flow.org", "https://flow.org"]);
device.enableSynchronization();
device.disableSynchronization();
device.resetContentAndSettings();
device.getPlatform();
github flow-typed / flow-typed / definitions / npm / detox_v7.x.x / test_detox_v7.x.x.js View on Github external
device.launchApp({ permissions: false, url: false });

// $ExpectError
device.terminateApp({ err: "err" });
device.terminateApp();
device.terminateApp("other.bundle.id");
device.reloadReactNative();
device.sendToHome();
device.installApp();
device.uninstallApp();
// $ExpectError
device.openURL({ url: "https://flow.org", sourceApp: false });
device.openURL({ url: "https://flow.org" });

// $ExpectError
device.sendUserNotification();
const userNotificationCalendarTrigger = {
  trigger: {
    type: "calendar",
    "date-components": {
      era: 1,
      year: 2017,
      month: 1,
      day: 1,
      hour: 0,
      minute: 0,
      second: 0,
      weekday: 0,
      weekdayOrdinal: 0,
      quarter: 1,
      weekOfMonth: 1,
      weekOfYear: 1,
github flow-typed / flow-typed / definitions / npm / detox_v7.x.x / test_detox_v7.x.x.js View on Github external
trigger: {
    type: "push"
  },
  title: "From push",
  subtitle: "Subtitle",
  body: "Body",
  badge: 1,
  payload: {
    key1: "value1",
    key2: "value2"
  },
  category: "com.example.category",
  "content-available": 0,
  "action-identifier": "default"
};
device.sendUserNotification(userNotificationCalendarTrigger);
device.sendUserNotification(userNotificationLocationTrigger);
device.sendUserNotification(userNotificationTimeIntervalTrigger);
device.sendUserNotification(userNotificationPushTrigger);

// $ExpectError
device.setOrientation("normal");
device.setOrientation("portrait");

// $ExpectError
device.setLocation();
device.setLocation(32.04, 34.78);

device.setURLBlacklist(["https://flow.org", "https://flow.org"]);
device.enableSynchronization();
device.disableSynchronization();
device.resetContentAndSettings();