SlideShare a Scribd company logo
Detox: tackling the flakiness of
mobile automation
Viktorija Sujetaitė | Mobile QA Engineer
viktorijas@wix.com
React Native: high level intro
Automation Testing
Detox: Overview
Configuration
Detox Object
Device Object
Actions, Matchers, Expectations
Manual Synchronization
Live Demo
AGENDA
01
React Native: a high level intro
What is React?
What is React Native?
Why React Native?
 We are JavaScript company (~500 FEDs);
 Wix knows and had great experience with React;
 Velocity (!);
 Multi-Platform solution;
 Behind React Native stands a big company (Facebook);
 Community.
Terminology
 Native – Developed for a specific platform.
 JS – Shared code between platforms.
 Components – UI elements provided by React Native or build on
demand.
 Bridge – Used by React Native to pass information between the
Native side and JS side and vice versa.
The Bridge
JavaScriptBridgeNative
User clicked a button in app:
User Click Native button
handler
N -> JS
Handler logic
Handler response
+ UI rendering
instructions
N <- JSBuild Native
views
Problems in React Native
 Maturity – new technology (since 2015);
 Documentation – it’s still in the making;
 No Platforms parity;
 No solid Navigation solution;
 Testing – native + JavaScript;
 The bridge – what should be allowed to go over it;
 Complex environment.
Native vs React Native
Native React Native
Objective-C/Swift/Java/Kotlin JavaScript
Static type Dynamic type
Multi-Threaded Single-Threaded
Simply run it Use Packager
Manual UI Flexbox
02
Automation testing
Types of automated tests
3 main types of automated tests:
• Unit tests;
• Mocked E2E;
• Production E2E.
Unit Tests
PROS CONS
Pure code oriented Pure code oriented
Easy to write + maintain Does not represent actual user flows
Improves code quality Does not reflect app quality
Find bugs easily
Mocked E2E
PROS CONS
Closer to code & product Hard to setup and write
Stable Gives limited confidence
Easy to maintain
Production E2E
PROS CONS
Mock real user experience Slow
Easy to setup Hard to maintain
Easy to write Less cost effective
High confidence Flaky
E2E Flakiness
Traditional method of dealing with flakiness is adding various
“sleep”
commands throughout the test.
Why?
To force a certain execution order.
03
Detox Overview
What is Detox?
In one sentence:
Gray box End-to-End testing and automation library
for mobile apps.
Detox is...
• Cross Platform – iOS and Android;
• Made for CI;
• Test Runner Independent;
• Automatically Synchronized.
Black Box vs Gray Box
Black Box A method of testing stuff from the outside,
without knowing what’s going on internally.
Gray Box Allows the test framework to monitor the app
from the inside and actually synchronize
with it.
Gray Box Sync
wait
No
Yes
Is app idle ? Advance
Two Running Parts
• The mobile app itself
Running on simulator;
• The test suite
Running on Node.js, outside of the app;
04
Detox Configuration
Device Configurations
• Defined in package.json file;
Param Details
binaryPath Relative path to the app due to be tested
testBinaryPath (optional, Android only): relative path to the test app (apk)
type
Device type, available options
are ios.simulator, ios.none, android.emulator, and android.attached.
name
Device name, aligns to the device list available through xcrun simctl
list
build [optional] Build command (either xcodebuild, react-native run-ios, etc...)
Example:
"detox": {
...
"configurations": {
"ios.sim.debug": {
"binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/example.app",
"build": "xcodebuild -project ios/example.xcodeproj -scheme example -configuration Debug
-sdk iphonesimulator -derivedDataPath ios/build",
"type": "ios.simulator",
"name": "iPhone 7 Plus"
}
}
}
Server and Test Runner
• Server configuration can be
specified generally or per specific
device configuration.
• Test Runner configuration is
Mocha by default, can define a
different one (e.g. Jest, AVA).
"detox": {
...
"session": {
"server": "ws://localhost:8099",
"sessionId": "YourProjectSessionId"
}
}
"detox": {
...
"test-runner": "jest"
"runner-config": "path/to/config.json"
}
Just Simply Run
detox test --configuration yourConfiguration
05
Detox Object
detox Object
• Globally available in every test file;
• 4 methods:
• detox.init();
• detox.beforeEach();
• detox.afterEach();
• detox.cleanup();
detox.init()
• Reads configuration;
• Starts a server;
• Loads its expectation library;
• Starts a simulator.
const config = require('../package.json').detox;
before(
async () => {
await detox.init(config, {launchApp: false});
}
);
detox.beforeEach()
• Called at the start of every test.
declare function beforeEach(testSummary: {
title: string;
fullName: string;
status: 'running';
})
detox.afterEach()
• Called at the end of the test;
• Must return failed or passed value.
declare function afterEach(testSummary: {
title: string;
fullName: string;
status: 'failed' | 'passed';
})
detox.cleanup()
• Should be triggered when detox.afterEach() finishes;
• Phase where Detox server shuts down.
after(async () => {
await detox.cleanup();
})
06
Device Object
device Object
• Globally available in every test file;
• Enables control over attached device;
• 18 different functions and counting.
device Object Functions
device.launchApp()
device.terminateApp()
device.sendToHome()
device.reloadReactNative()
device.installApp()
device.uninstallApp()
device.openURL(url)
device.sendUserNotification(params)
device.sendUserActivity(params)
device.setOrientation(orientation)
device.setLocation(lat, lon)
device.setURLBlacklist()
device.enableSynchronization()
device.disableSynchronization()
device.resetContentAndSettings()
device.getPlatform()
device.pressBack() Android Only
device.shake() iOS Only
device.launchApp()
Parameters to set:
restart app
set runtime permissions
add additional launch arguments
launch with notifications
launch with specific language
launch from a fresh installation
launch from URL
launch with user activity
disable touch indicators (iOS)
initialize the URL blacklist
device.launchApp()
await device.launchApp({
newInstance: true,
url: url,
userActivity: activity,
languageAndLocale: {
language: locale,
locale
},
permissions: {
calendar: 'Yes'
}
});
07
Actions, Matchers, Expectations
What are they for?
Matchers Actions Expectations
to find UI
elements
to emulate
user behavior
to verify
element
behavior
Matchers 🔎
by.id()
by.text()
by.label()
by.type()
by.traits()
for more
uniqueness:
.withAncestor()
.withDescendant()
.and()
Sometimes it’s not that easy...
Advanced Matchers
await element(by.id('toggle')
.withAncestor(by.id('notification_list_item')
.withDescendant(by.text('Allow Notifications’).toExist();
Actions 👉
.tap()
.longPress()
.multiTap()
.tapAtPoint()
.typeText()
.replaceText()
.clearText()
.scroll()
.scrollTo()
.swipe()
Tapping
.tap()
.longPress()
.multiTap()
.tapAtPoint()
Typing
.typeText()
.replaceText()
.clearText()
Scroll & Swipe
.scroll()
.scrollTo()
.swipe()
Expectations 🚀
.toBeVisible()
.toBeNotVisible()
.toExist()
.toNotExist()
.toHaveText()
.toHaveLabel()
.toHaveId()
.toHaveValue()
08
Manual Synchronization
Synchronization
• EarlGrey provides a synchronization mechanism;
• Tracks dispatch queue, operation queue, network, animations,
etc;
• Waits for app to be idle.
What if app does not become idle?
Disabling
• App is busy – does not reach
idle state;
• Usual use case – animated
elements;
• Disable before entering screen
with such element;
Enabling
• Enable when in idle screen;
• Resets with every new app
instance.
waitFor()⏱
• Manual sync;
• Must have a timeout;
• Use together with an expectation.
await waitFor(element(by.id('UniqueId204'))).toBeVisible().withTimeout(2000);
await expect(element(by.id('UniqueId204'))).toBeVisible();
Live
Demo
Demo
Scenario:
• log into the app;
• join a site with Invite Code;
• verify site in Home tab;
• hide site from Home tab;
• unhide site;
• verify it’s visible.
Q&A
viktorijas@wix.com
Detox @ GitHub | https://github.com/wix/detox

More Related Content

What's hot

API Testing Presentations.pptx
API Testing Presentations.pptxAPI Testing Presentations.pptx
API Testing Presentations.pptx
ManmitSalunke
 
Appium: Automation for Mobile Apps
Appium: Automation for Mobile AppsAppium: Automation for Mobile Apps
Appium: Automation for Mobile Apps
Sauce Labs
 
Introducción a Wiremock
Introducción a WiremockIntroducción a Wiremock
Introducción a Wiremock
Jose Ortiz
 
Retrofit
RetrofitRetrofit
Retrofit
Amin Cheloh
 
Automation - web testing with selenium
Automation - web testing with seleniumAutomation - web testing with selenium
Automation - web testing with selenium
Tzirla Rozental
 
Guide to Destroying Codebases The Demise of Clever Code
Guide to Destroying Codebases   The Demise of Clever CodeGuide to Destroying Codebases   The Demise of Clever Code
Guide to Destroying Codebases The Demise of Clever Code
Gabor Varadi
 
Selenium
SeleniumSelenium
Selenium
Adam Goucher
 
Test Design and Automation for REST API
Test Design and Automation for REST APITest Design and Automation for REST API
Test Design and Automation for REST API
Ivan Katunou
 
Automation Testing by Selenium Web Driver
Automation Testing by Selenium Web DriverAutomation Testing by Selenium Web Driver
Automation Testing by Selenium Web Driver
Cuelogic Technologies Pvt. Ltd.
 
Mockito
MockitoMockito
Belajar Postman test runner
Belajar Postman test runnerBelajar Postman test runner
Belajar Postman test runner
Fachrul Choliluddin
 
Introduction To Mobile-Automation
Introduction To Mobile-AutomationIntroduction To Mobile-Automation
Introduction To Mobile-Automation
Mindfire Solutions
 
Testing in-python-and-pytest-framework
Testing in-python-and-pytest-frameworkTesting in-python-and-pytest-framework
Testing in-python-and-pytest-framework
Arulalan T
 
API Testing. Streamline your testing process.
API Testing. Streamline your testing process.API Testing. Streamline your testing process.
API Testing. Streamline your testing process.
Andrey Oleynik
 
TestComplete – A Sophisticated Automated Testing Tool by SmartBear
TestComplete – A Sophisticated Automated Testing Tool by SmartBearTestComplete – A Sophisticated Automated Testing Tool by SmartBear
TestComplete – A Sophisticated Automated Testing Tool by SmartBear
Software Testing Solution
 
Handle Exceptions in Selenium Webdriver | Edureka
Handle Exceptions in Selenium Webdriver | EdurekaHandle Exceptions in Selenium Webdriver | Edureka
Handle Exceptions in Selenium Webdriver | Edureka
Edureka!
 
Test NG Framework Complete Walk Through
Test NG Framework Complete Walk ThroughTest NG Framework Complete Walk Through
Test NG Framework Complete Walk Through
Narendran Solai Sridharan
 
JUnit 5
JUnit 5JUnit 5
Mobile Application Testing Strategy
Mobile Application Testing StrategyMobile Application Testing Strategy
Mobile Application Testing Strategy
ankitQA
 
An introduction to api testing | David Tzemach
An introduction to api testing | David TzemachAn introduction to api testing | David Tzemach
An introduction to api testing | David Tzemach
David Tzemach
 

What's hot (20)

API Testing Presentations.pptx
API Testing Presentations.pptxAPI Testing Presentations.pptx
API Testing Presentations.pptx
 
Appium: Automation for Mobile Apps
Appium: Automation for Mobile AppsAppium: Automation for Mobile Apps
Appium: Automation for Mobile Apps
 
Introducción a Wiremock
Introducción a WiremockIntroducción a Wiremock
Introducción a Wiremock
 
Retrofit
RetrofitRetrofit
Retrofit
 
Automation - web testing with selenium
Automation - web testing with seleniumAutomation - web testing with selenium
Automation - web testing with selenium
 
Guide to Destroying Codebases The Demise of Clever Code
Guide to Destroying Codebases   The Demise of Clever CodeGuide to Destroying Codebases   The Demise of Clever Code
Guide to Destroying Codebases The Demise of Clever Code
 
Selenium
SeleniumSelenium
Selenium
 
Test Design and Automation for REST API
Test Design and Automation for REST APITest Design and Automation for REST API
Test Design and Automation for REST API
 
Automation Testing by Selenium Web Driver
Automation Testing by Selenium Web DriverAutomation Testing by Selenium Web Driver
Automation Testing by Selenium Web Driver
 
Mockito
MockitoMockito
Mockito
 
Belajar Postman test runner
Belajar Postman test runnerBelajar Postman test runner
Belajar Postman test runner
 
Introduction To Mobile-Automation
Introduction To Mobile-AutomationIntroduction To Mobile-Automation
Introduction To Mobile-Automation
 
Testing in-python-and-pytest-framework
Testing in-python-and-pytest-frameworkTesting in-python-and-pytest-framework
Testing in-python-and-pytest-framework
 
API Testing. Streamline your testing process.
API Testing. Streamline your testing process.API Testing. Streamline your testing process.
API Testing. Streamline your testing process.
 
TestComplete – A Sophisticated Automated Testing Tool by SmartBear
TestComplete – A Sophisticated Automated Testing Tool by SmartBearTestComplete – A Sophisticated Automated Testing Tool by SmartBear
TestComplete – A Sophisticated Automated Testing Tool by SmartBear
 
Handle Exceptions in Selenium Webdriver | Edureka
Handle Exceptions in Selenium Webdriver | EdurekaHandle Exceptions in Selenium Webdriver | Edureka
Handle Exceptions in Selenium Webdriver | Edureka
 
Test NG Framework Complete Walk Through
Test NG Framework Complete Walk ThroughTest NG Framework Complete Walk Through
Test NG Framework Complete Walk Through
 
JUnit 5
JUnit 5JUnit 5
JUnit 5
 
Mobile Application Testing Strategy
Mobile Application Testing StrategyMobile Application Testing Strategy
Mobile Application Testing Strategy
 
An introduction to api testing | David Tzemach
An introduction to api testing | David TzemachAn introduction to api testing | David Tzemach
An introduction to api testing | David Tzemach
 

Similar to Detox: tackling the flakiness of mobile automation

QA Fest 2018. Adam Stasiak. React Native is Coming – the story of hybrid mobi...
QA Fest 2018. Adam Stasiak. React Native is Coming – the story of hybrid mobi...QA Fest 2018. Adam Stasiak. React Native is Coming – the story of hybrid mobi...
QA Fest 2018. Adam Stasiak. React Native is Coming – the story of hybrid mobi...
QAFest
 
Shifting landscape of mobile automation, and the future of Appium - Jonathan ...
Shifting landscape of mobile automation, and the future of Appium - Jonathan ...Shifting landscape of mobile automation, and the future of Appium - Jonathan ...
Shifting landscape of mobile automation, and the future of Appium - Jonathan ...
Applitools
 
Guide to End-to-End Detox Testing Headspin
Guide to End-to-End Detox Testing HeadspinGuide to End-to-End Detox Testing Headspin
Guide to End-to-End Detox Testing Headspin
flufftailshop
 
Unit Tesing in iOS
Unit Tesing in iOSUnit Tesing in iOS
Unit Tesing in iOS
Ciklum Ukraine
 
Top100summit 谷歌-scott-improve your automated web application testing
Top100summit  谷歌-scott-improve your automated web application testingTop100summit  谷歌-scott-improve your automated web application testing
Top100summit 谷歌-scott-improve your automated web application testing
drewz lin
 
Android Building, Testing and reversing
Android Building, Testing and reversingAndroid Building, Testing and reversing
Android Building, Testing and reversing
Enrique López Mañas
 
A. Sirota "Building an Automation Solution based on Appium"
A. Sirota "Building an Automation Solution based on Appium"A. Sirota "Building an Automation Solution based on Appium"
A. Sirota "Building an Automation Solution based on Appium"
DataArt
 
Testing and Building Android
Testing and Building AndroidTesting and Building Android
Testing and Building Android
Droidcon Berlin
 
Behavior Driven Development by Example
Behavior Driven Development by ExampleBehavior Driven Development by Example
Behavior Driven Development by Example
Nalin Goonawardana
 
Pragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScriptPragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScript
davejohnson
 
Hybrid application development
Hybrid application developmentHybrid application development
Hybrid application development
Engin Hatay
 
[QE 2018] Adam Stasiak – Nadchodzi React Native – czyli o testowaniu mobilnyc...
[QE 2018] Adam Stasiak – Nadchodzi React Native – czyli o testowaniu mobilnyc...[QE 2018] Adam Stasiak – Nadchodzi React Native – czyli o testowaniu mobilnyc...
[QE 2018] Adam Stasiak – Nadchodzi React Native – czyli o testowaniu mobilnyc...
Future Processing
 
Robotium at Android Only 2010-09-29
Robotium at Android Only 2010-09-29Robotium at Android Only 2010-09-29
Robotium at Android Only 2010-09-29
Hugo Josefson
 
Uber Mobility Meetup: Mobile Testing
Uber Mobility Meetup:  Mobile TestingUber Mobility Meetup:  Mobile Testing
Uber Mobility Meetup: Mobile Testing
Apple Chow
 
Software testing: an introduction - 2017
Software testing: an introduction - 2017Software testing: an introduction - 2017
Software testing: an introduction - 2017
XavierDevroey
 
Droidcon Spain 2016 - The Pragmatic Android Programmer: from hype to reality
 Droidcon Spain 2016 - The Pragmatic Android Programmer: from hype to reality Droidcon Spain 2016 - The Pragmatic Android Programmer: from hype to reality
Droidcon Spain 2016 - The Pragmatic Android Programmer: from hype to reality
Daniel Gallego Vico
 
Grails unit testing
Grails unit testingGrails unit testing
Grails unit testing
pleeps
 
React Native: The Development Flow
React Native: The Development FlowReact Native: The Development Flow
React Native: The Development Flow
Ritesh Kumar
 
[1D1]신개념 N스크린 웹 앱 프레임워크 PARS
[1D1]신개념 N스크린 웹 앱 프레임워크 PARS[1D1]신개념 N스크린 웹 앱 프레임워크 PARS
[1D1]신개념 N스크린 웹 앱 프레임워크 PARS
NAVER D2
 
Espresso workshop
Espresso workshopEspresso workshop
Espresso workshop
Ketan Soni
 

Similar to Detox: tackling the flakiness of mobile automation (20)

QA Fest 2018. Adam Stasiak. React Native is Coming – the story of hybrid mobi...
QA Fest 2018. Adam Stasiak. React Native is Coming – the story of hybrid mobi...QA Fest 2018. Adam Stasiak. React Native is Coming – the story of hybrid mobi...
QA Fest 2018. Adam Stasiak. React Native is Coming – the story of hybrid mobi...
 
Shifting landscape of mobile automation, and the future of Appium - Jonathan ...
Shifting landscape of mobile automation, and the future of Appium - Jonathan ...Shifting landscape of mobile automation, and the future of Appium - Jonathan ...
Shifting landscape of mobile automation, and the future of Appium - Jonathan ...
 
Guide to End-to-End Detox Testing Headspin
Guide to End-to-End Detox Testing HeadspinGuide to End-to-End Detox Testing Headspin
Guide to End-to-End Detox Testing Headspin
 
Unit Tesing in iOS
Unit Tesing in iOSUnit Tesing in iOS
Unit Tesing in iOS
 
Top100summit 谷歌-scott-improve your automated web application testing
Top100summit  谷歌-scott-improve your automated web application testingTop100summit  谷歌-scott-improve your automated web application testing
Top100summit 谷歌-scott-improve your automated web application testing
 
Android Building, Testing and reversing
Android Building, Testing and reversingAndroid Building, Testing and reversing
Android Building, Testing and reversing
 
A. Sirota "Building an Automation Solution based on Appium"
A. Sirota "Building an Automation Solution based on Appium"A. Sirota "Building an Automation Solution based on Appium"
A. Sirota "Building an Automation Solution based on Appium"
 
Testing and Building Android
Testing and Building AndroidTesting and Building Android
Testing and Building Android
 
Behavior Driven Development by Example
Behavior Driven Development by ExampleBehavior Driven Development by Example
Behavior Driven Development by Example
 
Pragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScriptPragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScript
 
Hybrid application development
Hybrid application developmentHybrid application development
Hybrid application development
 
[QE 2018] Adam Stasiak – Nadchodzi React Native – czyli o testowaniu mobilnyc...
[QE 2018] Adam Stasiak – Nadchodzi React Native – czyli o testowaniu mobilnyc...[QE 2018] Adam Stasiak – Nadchodzi React Native – czyli o testowaniu mobilnyc...
[QE 2018] Adam Stasiak – Nadchodzi React Native – czyli o testowaniu mobilnyc...
 
Robotium at Android Only 2010-09-29
Robotium at Android Only 2010-09-29Robotium at Android Only 2010-09-29
Robotium at Android Only 2010-09-29
 
Uber Mobility Meetup: Mobile Testing
Uber Mobility Meetup:  Mobile TestingUber Mobility Meetup:  Mobile Testing
Uber Mobility Meetup: Mobile Testing
 
Software testing: an introduction - 2017
Software testing: an introduction - 2017Software testing: an introduction - 2017
Software testing: an introduction - 2017
 
Droidcon Spain 2016 - The Pragmatic Android Programmer: from hype to reality
 Droidcon Spain 2016 - The Pragmatic Android Programmer: from hype to reality Droidcon Spain 2016 - The Pragmatic Android Programmer: from hype to reality
Droidcon Spain 2016 - The Pragmatic Android Programmer: from hype to reality
 
Grails unit testing
Grails unit testingGrails unit testing
Grails unit testing
 
React Native: The Development Flow
React Native: The Development FlowReact Native: The Development Flow
React Native: The Development Flow
 
[1D1]신개념 N스크린 웹 앱 프레임워크 PARS
[1D1]신개념 N스크린 웹 앱 프레임워크 PARS[1D1]신개념 N스크린 웹 앱 프레임워크 PARS
[1D1]신개념 N스크린 웹 앱 프레임워크 PARS
 
Espresso workshop
Espresso workshopEspresso workshop
Espresso workshop
 

Detox: tackling the flakiness of mobile automation