SlideShare a Scribd company logo
1 of 89
Download to read offline
Effective Detox Testing
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
Overview
1. What kinds of things to test with Detox
2. Faking the API layer
3. How much of your app to test with Detox
4. Detox on CI
5. Local Detox development workflow
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
Prerequisites
— Experience with React Native
— Experience with Detox
— Experience with different types of tests: unit,
component, end-to-end
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
Josh Justice
CodingItWrong.com
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
ReactNativeTesting.io
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
https://rnte.st/london23
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
1. What kinds of things to
test with Detox
…vs. what kinds of things to test
with other tools
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
Kinds of Testing
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
"Testing is all about
confidence."
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
Realism != Confidence
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
Realism like…
— Get a push notification
— OS alert prompts you to apply an OS update
— Network connection drops
— Virtual keyboard appears/disappears when you don't
expect
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
A less-realistic, stable test
gives you more confidence than
a realistic, flaky test.
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
A less-realistic test you run
all the time
gives you more confidence than
a realistic test you don't run
because it's slow.
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
Testing Goals
— Realism
— Speed
— Reliability
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
Manual Testing
— Animation smoothness
— User experience
— Integration with third-party
services
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
End-to-End Testing
— Integration of first-party and
third-party JS and native code
— Can the user do what they
want to do?
— Can the app make money?
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
Component Testing
— Fully cover logical branches in
UI code
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
Unit Testing
— Fully cover logical branches in
non-UI code
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
The more realistic the test,
the more effort it is to write
and maintain it.
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
Test Pyramid
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
Test Pyramid
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
Questions?
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
2. Faking the API Layer
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
Connecting to the real backend:
Upsides?
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
Connecting to the real backend:
Downsides?
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
App Layers
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
Options for Mocking Web Service Requests
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
Local web server?
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
Options for Mocking Web Service Requests
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
Fake Module
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
What's a fake?
A version of the service that acts similar to the real thing
but stores its data in-memory
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
To the code!
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
API file setup
api.js
api.mock.js
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
api.js
import axios from 'axios';
const api = axios.create({
baseURL: 'https://api.reactnativetesting.io',
// other config
});
export default api;
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
api.mock.js
const api = {
get() {
return Promise.resolve({
data: [
{id: 1, name: 'Widget 1'},
{id: 2, name: 'Widget 2'},
]
});
},
// ...
};
export default api;
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
Configure metro.config.js
— When flag is set, prefer .mock.js extension when
present
— Exact code may differ if you've modified
metro.config.js for other reasons
— E.g. using react-native-svg-transformer
— See reactnativetesting.io/e2e/external-services
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
package.json
"start": "react-native start",
+"start:mock": "MOCK_API=true npm run start",
"test": "jest"
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
For Windows support
"start": "react-native start",
+"start:mock": "cross-env MOCK_API=true npm run start",
"test": "jest"
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
Questions?
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
3. How Much to Test with
Detox
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
To the code!
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
Types of Detox Test (not rigid categories)
— Boot test
— Play-around test
— The most important moneymaking feature, happy
path flow
— Secondary feature happy paths
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
Factors
— Flake
— Test speed
— Ease of writing
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
Types of Detox Test (not rigid categories)
— Boot test
— Play-around test
— The most important moneymaking feature, happy
path flow
— Secondary feature happy paths
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
Questions?
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
4. Detox on CI
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
CI for native mobile apps is
hard
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
1. Variations between CI
Platforms
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
2. Dependent on details of
specific versions
On GitHub Actions, Detox works for me on macos-12
and times out on macos-13
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
3. Slow
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
4. Expensive if you pay by the
hour
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
5. If you have a suite that passes
on developer machines, it's hard
to get it all passing on CI at once
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
My GitHub Actions Detox
CI Setup
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
To the YAML!
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
name: Detox
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
jobs:
test:
runs-on: macos-12
steps:
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 18
cache: "yarn"
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
- name: Cache Pods dependencies
uses: actions/cache@v3
with:
path: ios/Pods
key: ${{ runner.OS }}-pods-cache-${{ hashFiles('**/ios/Podfile.lock') }}
restore-keys: |
${{ runner.OS }}-pods-cache-
- name: Install npm dependencies
run: yarn install --frozen-lockfile
- name: Install iOS dependencies
run: npx pod-install
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
- name: Install Detox CLI
run: |
brew tap wix/brew
brew install applesimutils
npm install -g detox-cli
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
- name: Build App for Detox
run: detox build -c ios.sim.release
- uses: futureware-tech/simulator-action@v2
with:
model: "iPhone 14"
- name: Run Detox
run: detox test -c ios.sim.release
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
Recommendation
— Pick your potential CI platform
— Try to get a boot test passing on CI
— If it doesn't work, try another platform
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
5. Local Detox development
workflow
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
3 Stages
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
Stage 1: Test Existing
Features
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
Stage 2: Test Features As
You Add
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
Stage 3: Test-Driven
Development
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
Getting Better All
the Time: How to
Escape Bad Code
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
To the code!
learntdd.in/react-native
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
Why TDD?
— Thorough test coverage.
— Code that is easy to test.
— Minimal code.
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
3 Stages
1. Test some existing features
2. Test new features as you add them
3. Test-driven development
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
Questions?
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
What We Covered
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
1. What kinds of things to test with Detox
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
1. What kinds of things to test with Detox
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
2. Faking the API layer
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
3. How much to test with Detox
— Boot test
— Play-around test
— The most important moneymaking feature, happy
path flow
— Secondary feature happy paths
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
4. Detox on CI
GitHub Actions example config
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
5. Stages of Detox development
1. Test some existing features
2. Test new features as you add them
3. Test-driven development
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
What We Covered
1. What kinds of things to test with Detox
2. Faking the API layer
3. How much of your app to test with Detox
4. Detox on CI
5. Local Detox development workflow
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
Thanks!
Questions?
Josh Justice
josh.justice@testdouble.com
https://rnte.st/london23
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
Thanks!
Josh Justice
josh.justice@testdouble.com
https://rnte.st/london23
Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23

More Related Content

Similar to Effective Detox Testing Strategies

Managing microservices with istio on OpenShift - Meetup
Managing microservices with istio on OpenShift - MeetupManaging microservices with istio on OpenShift - Meetup
Managing microservices with istio on OpenShift - MeetupJosé Román Martín Gil
 
An Introduction to AngularJS End to End Testing using Protractor
An Introduction to AngularJS End to End Testing using ProtractorAn Introduction to AngularJS End to End Testing using Protractor
An Introduction to AngularJS End to End Testing using ProtractorCubet Techno Labs
 
Abusing JavaScript to Measure Web Performance
Abusing JavaScript to Measure Web PerformanceAbusing JavaScript to Measure Web Performance
Abusing JavaScript to Measure Web PerformancePhilip Tellis
 
Enabling Microservices @Orbitz - Velocity Conf 2015
Enabling Microservices @Orbitz - Velocity Conf 2015Enabling Microservices @Orbitz - Velocity Conf 2015
Enabling Microservices @Orbitz - Velocity Conf 2015Steve Hoffman
 
3h à l'assaut d'une application réactive - Devoxx 2015
3h à l'assaut d'une application réactive - Devoxx 20153h à l'assaut d'une application réactive - Devoxx 2015
3h à l'assaut d'une application réactive - Devoxx 2015Publicis Sapient Engineering
 
Overseeing Ship's Surveys and Surveyors Globally Using IoT and Docker by Jay ...
Overseeing Ship's Surveys and Surveyors Globally Using IoT and Docker by Jay ...Overseeing Ship's Surveys and Surveyors Globally Using IoT and Docker by Jay ...
Overseeing Ship's Surveys and Surveyors Globally Using IoT and Docker by Jay ...Docker, Inc.
 
Jakarta EE for Spring Developers
Jakarta EE for Spring DevelopersJakarta EE for Spring Developers
Jakarta EE for Spring DevelopersIvar Grimstad
 
Droidcon Online 2020 quick summary
Droidcon Online 2020 quick summaryDroidcon Online 2020 quick summary
Droidcon Online 2020 quick summaryBartosz Kosarzycki
 
DevOps: Find Solutions, Not More Defects
DevOps: Find Solutions, Not More DefectsDevOps: Find Solutions, Not More Defects
DevOps: Find Solutions, Not More DefectsTechWell
 
Bot or not? Detecting bots in GitHub pull request activity based on comment s...
Bot or not? Detecting bots in GitHub pull request activity based on comment s...Bot or not? Detecting bots in GitHub pull request activity based on comment s...
Bot or not? Detecting bots in GitHub pull request activity based on comment s...Tom Mens
 
apidays Australia 2022 - Spinning Your Drones with Cadence Workflows and Apac...
apidays Australia 2022 - Spinning Your Drones with Cadence Workflows and Apac...apidays Australia 2022 - Spinning Your Drones with Cadence Workflows and Apac...
apidays Australia 2022 - Spinning Your Drones with Cadence Workflows and Apac...apidays
 
Multiplatform architecture ribs in swift
Multiplatform architecture ribs in swiftMultiplatform architecture ribs in swift
Multiplatform architecture ribs in swiftNAVER Engineering
 
Ivan Dryzhyruk “Ducks Don’t Like Bugs”
Ivan Dryzhyruk “Ducks Don’t Like Bugs”Ivan Dryzhyruk “Ducks Don’t Like Bugs”
Ivan Dryzhyruk “Ducks Don’t Like Bugs”LogeekNightUkraine
 
Don't screw it up: how to build durable web apis @ PHPDay 2014 in Verona (ITA)
Don't screw it up: how to build durable web apis @ PHPDay 2014 in Verona (ITA)Don't screw it up: how to build durable web apis @ PHPDay 2014 in Verona (ITA)
Don't screw it up: how to build durable web apis @ PHPDay 2014 in Verona (ITA)Alessandro Nadalin
 
Don't screw it up: how to build durable web apis
Don't screw it up: how to build durable web apisDon't screw it up: how to build durable web apis
Don't screw it up: how to build durable web apisAlessandro Cinelli (cirpo)
 
Modern Release Engineering in a Nutshell - Why Researchers should Care!
Modern Release Engineering in a Nutshell - Why Researchers should Care!Modern Release Engineering in a Nutshell - Why Researchers should Care!
Modern Release Engineering in a Nutshell - Why Researchers should Care!Bram Adams
 
Open stack gbp final sn-4-slideshare
Open stack gbp final sn-4-slideshareOpen stack gbp final sn-4-slideshare
Open stack gbp final sn-4-slideshareSumit Naiksatam
 
The Physical World meets the Web
The Physical World meets the WebThe Physical World meets the Web
The Physical World meets the WebMaximiliano Firtman
 
Contract testing. Isolated testing of microservices with pact.io - Evgeniy Ku...
Contract testing. Isolated testing of microservices with pact.io - Evgeniy Ku...Contract testing. Isolated testing of microservices with pact.io - Evgeniy Ku...
Contract testing. Isolated testing of microservices with pact.io - Evgeniy Ku...Evgeniy Kuzmin
 

Similar to Effective Detox Testing Strategies (20)

Managing microservices with istio on OpenShift - Meetup
Managing microservices with istio on OpenShift - MeetupManaging microservices with istio on OpenShift - Meetup
Managing microservices with istio on OpenShift - Meetup
 
An Introduction to AngularJS End to End Testing using Protractor
An Introduction to AngularJS End to End Testing using ProtractorAn Introduction to AngularJS End to End Testing using Protractor
An Introduction to AngularJS End to End Testing using Protractor
 
Abusing JavaScript to Measure Web Performance
Abusing JavaScript to Measure Web PerformanceAbusing JavaScript to Measure Web Performance
Abusing JavaScript to Measure Web Performance
 
Enabling Microservices @Orbitz - Velocity Conf 2015
Enabling Microservices @Orbitz - Velocity Conf 2015Enabling Microservices @Orbitz - Velocity Conf 2015
Enabling Microservices @Orbitz - Velocity Conf 2015
 
3h à l'assaut d'une application réactive - Devoxx 2015
3h à l'assaut d'une application réactive - Devoxx 20153h à l'assaut d'une application réactive - Devoxx 2015
3h à l'assaut d'une application réactive - Devoxx 2015
 
Overseeing Ship's Surveys and Surveyors Globally Using IoT and Docker by Jay ...
Overseeing Ship's Surveys and Surveyors Globally Using IoT and Docker by Jay ...Overseeing Ship's Surveys and Surveyors Globally Using IoT and Docker by Jay ...
Overseeing Ship's Surveys and Surveyors Globally Using IoT and Docker by Jay ...
 
Jakarta EE for Spring Developers
Jakarta EE for Spring DevelopersJakarta EE for Spring Developers
Jakarta EE for Spring Developers
 
Droidcon Online 2020 quick summary
Droidcon Online 2020 quick summaryDroidcon Online 2020 quick summary
Droidcon Online 2020 quick summary
 
DevOps: Find Solutions, Not More Defects
DevOps: Find Solutions, Not More DefectsDevOps: Find Solutions, Not More Defects
DevOps: Find Solutions, Not More Defects
 
Bot or not? Detecting bots in GitHub pull request activity based on comment s...
Bot or not? Detecting bots in GitHub pull request activity based on comment s...Bot or not? Detecting bots in GitHub pull request activity based on comment s...
Bot or not? Detecting bots in GitHub pull request activity based on comment s...
 
apidays Australia 2022 - Spinning Your Drones with Cadence Workflows and Apac...
apidays Australia 2022 - Spinning Your Drones with Cadence Workflows and Apac...apidays Australia 2022 - Spinning Your Drones with Cadence Workflows and Apac...
apidays Australia 2022 - Spinning Your Drones with Cadence Workflows and Apac...
 
PhD Dissertation Defense (April 2015)
PhD Dissertation Defense (April 2015)PhD Dissertation Defense (April 2015)
PhD Dissertation Defense (April 2015)
 
Multiplatform architecture ribs in swift
Multiplatform architecture ribs in swiftMultiplatform architecture ribs in swift
Multiplatform architecture ribs in swift
 
Ivan Dryzhyruk “Ducks Don’t Like Bugs”
Ivan Dryzhyruk “Ducks Don’t Like Bugs”Ivan Dryzhyruk “Ducks Don’t Like Bugs”
Ivan Dryzhyruk “Ducks Don’t Like Bugs”
 
Don't screw it up: how to build durable web apis @ PHPDay 2014 in Verona (ITA)
Don't screw it up: how to build durable web apis @ PHPDay 2014 in Verona (ITA)Don't screw it up: how to build durable web apis @ PHPDay 2014 in Verona (ITA)
Don't screw it up: how to build durable web apis @ PHPDay 2014 in Verona (ITA)
 
Don't screw it up: how to build durable web apis
Don't screw it up: how to build durable web apisDon't screw it up: how to build durable web apis
Don't screw it up: how to build durable web apis
 
Modern Release Engineering in a Nutshell - Why Researchers should Care!
Modern Release Engineering in a Nutshell - Why Researchers should Care!Modern Release Engineering in a Nutshell - Why Researchers should Care!
Modern Release Engineering in a Nutshell - Why Researchers should Care!
 
Open stack gbp final sn-4-slideshare
Open stack gbp final sn-4-slideshareOpen stack gbp final sn-4-slideshare
Open stack gbp final sn-4-slideshare
 
The Physical World meets the Web
The Physical World meets the WebThe Physical World meets the Web
The Physical World meets the Web
 
Contract testing. Isolated testing of microservices with pact.io - Evgeniy Ku...
Contract testing. Isolated testing of microservices with pact.io - Evgeniy Ku...Contract testing. Isolated testing of microservices with pact.io - Evgeniy Ku...
Contract testing. Isolated testing of microservices with pact.io - Evgeniy Ku...
 

More from Josh Justice

Designing Effective Tests with React Testing Library - React Day Berlin 2022
Designing Effective Tests with React Testing Library - React Day Berlin 2022Designing Effective Tests with React Testing Library - React Day Berlin 2022
Designing Effective Tests with React Testing Library - React Day Berlin 2022Josh Justice
 
Building for Mobile and Web with Expo - React Day Berlin 2022
Building for Mobile and Web with Expo - React Day Berlin 2022Building for Mobile and Web with Expo - React Day Berlin 2022
Building for Mobile and Web with Expo - React Day Berlin 2022Josh Justice
 
Getting Better All the Time: How to Escape Bad Code
Getting Better All the Time: How to Escape Bad CodeGetting Better All the Time: How to Escape Bad Code
Getting Better All the Time: How to Escape Bad CodeJosh Justice
 
Sustainable Learning - ReactATL Jan 2022
Sustainable Learning - ReactATL Jan 2022Sustainable Learning - ReactATL Jan 2022
Sustainable Learning - ReactATL Jan 2022Josh Justice
 
Building an App for Mobile and Web with Expo
Building an App for Mobile and Web with ExpoBuilding an App for Mobile and Web with Expo
Building an App for Mobile and Web with ExpoJosh Justice
 
User-Modifiable Software: Smalltalk and HyperCard
User-Modifiable Software: Smalltalk and HyperCardUser-Modifiable Software: Smalltalk and HyperCard
User-Modifiable Software: Smalltalk and HyperCardJosh Justice
 
Practical Accessibility (A11y)
Practical Accessibility (A11y)Practical Accessibility (A11y)
Practical Accessibility (A11y)Josh Justice
 
Old Solutions to New Testing Problems
Old Solutions to New Testing ProblemsOld Solutions to New Testing Problems
Old Solutions to New Testing ProblemsJosh Justice
 
Test-Driven Development in Vue with Cypress
Test-Driven Development in Vue with CypressTest-Driven Development in Vue with Cypress
Test-Driven Development in Vue with CypressJosh Justice
 
Test-Driven Development in React with Cypress
Test-Driven Development in React with CypressTest-Driven Development in React with Cypress
Test-Driven Development in React with CypressJosh Justice
 
Newbie's Guide to Contributing to Babel
Newbie's Guide to Contributing to BabelNewbie's Guide to Contributing to Babel
Newbie's Guide to Contributing to BabelJosh Justice
 
Outside-in Testing in Vue with Cypress
Outside-in Testing in Vue with CypressOutside-in Testing in Vue with Cypress
Outside-in Testing in Vue with CypressJosh Justice
 

More from Josh Justice (12)

Designing Effective Tests with React Testing Library - React Day Berlin 2022
Designing Effective Tests with React Testing Library - React Day Berlin 2022Designing Effective Tests with React Testing Library - React Day Berlin 2022
Designing Effective Tests with React Testing Library - React Day Berlin 2022
 
Building for Mobile and Web with Expo - React Day Berlin 2022
Building for Mobile and Web with Expo - React Day Berlin 2022Building for Mobile and Web with Expo - React Day Berlin 2022
Building for Mobile and Web with Expo - React Day Berlin 2022
 
Getting Better All the Time: How to Escape Bad Code
Getting Better All the Time: How to Escape Bad CodeGetting Better All the Time: How to Escape Bad Code
Getting Better All the Time: How to Escape Bad Code
 
Sustainable Learning - ReactATL Jan 2022
Sustainable Learning - ReactATL Jan 2022Sustainable Learning - ReactATL Jan 2022
Sustainable Learning - ReactATL Jan 2022
 
Building an App for Mobile and Web with Expo
Building an App for Mobile and Web with ExpoBuilding an App for Mobile and Web with Expo
Building an App for Mobile and Web with Expo
 
User-Modifiable Software: Smalltalk and HyperCard
User-Modifiable Software: Smalltalk and HyperCardUser-Modifiable Software: Smalltalk and HyperCard
User-Modifiable Software: Smalltalk and HyperCard
 
Practical Accessibility (A11y)
Practical Accessibility (A11y)Practical Accessibility (A11y)
Practical Accessibility (A11y)
 
Old Solutions to New Testing Problems
Old Solutions to New Testing ProblemsOld Solutions to New Testing Problems
Old Solutions to New Testing Problems
 
Test-Driven Development in Vue with Cypress
Test-Driven Development in Vue with CypressTest-Driven Development in Vue with Cypress
Test-Driven Development in Vue with Cypress
 
Test-Driven Development in React with Cypress
Test-Driven Development in React with CypressTest-Driven Development in React with Cypress
Test-Driven Development in React with Cypress
 
Newbie's Guide to Contributing to Babel
Newbie's Guide to Contributing to BabelNewbie's Guide to Contributing to Babel
Newbie's Guide to Contributing to Babel
 
Outside-in Testing in Vue with Cypress
Outside-in Testing in Vue with CypressOutside-in Testing in Vue with Cypress
Outside-in Testing in Vue with Cypress
 

Recently uploaded

Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 

Recently uploaded (20)

Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 

Effective Detox Testing Strategies

  • 1. Effective Detox Testing Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 2. Overview 1. What kinds of things to test with Detox 2. Faking the API layer 3. How much of your app to test with Detox 4. Detox on CI 5. Local Detox development workflow Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 3. Prerequisites — Experience with React Native — Experience with Detox — Experience with different types of tests: unit, component, end-to-end Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 4. Josh Justice CodingItWrong.com Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 5. ReactNativeTesting.io Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 6. Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 7. https://rnte.st/london23 Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 8. 1. What kinds of things to test with Detox …vs. what kinds of things to test with other tools Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 9. Kinds of Testing Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 10. Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 11. Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 12. Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 13. Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 14. Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 15. Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 16. "Testing is all about confidence." Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 17. Realism != Confidence Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 18. Realism like… — Get a push notification — OS alert prompts you to apply an OS update — Network connection drops — Virtual keyboard appears/disappears when you don't expect Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 19. A less-realistic, stable test gives you more confidence than a realistic, flaky test. Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 20. A less-realistic test you run all the time gives you more confidence than a realistic test you don't run because it's slow. Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 21. Testing Goals — Realism — Speed — Reliability Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 22. Manual Testing — Animation smoothness — User experience — Integration with third-party services Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 23. End-to-End Testing — Integration of first-party and third-party JS and native code — Can the user do what they want to do? — Can the app make money? Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 24. Component Testing — Fully cover logical branches in UI code Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 25. Unit Testing — Fully cover logical branches in non-UI code Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 26. The more realistic the test, the more effort it is to write and maintain it. Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 27. Test Pyramid Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 28. Test Pyramid Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 29. Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 30. Questions? Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 31. 2. Faking the API Layer Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 32. Connecting to the real backend: Upsides? Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 33. Connecting to the real backend: Downsides? Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 34. App Layers Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 35. Options for Mocking Web Service Requests Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 36. Local web server? Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 37. Options for Mocking Web Service Requests Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 38. Fake Module Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 39. What's a fake? A version of the service that acts similar to the real thing but stores its data in-memory Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 40. To the code! Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 41. API file setup api.js api.mock.js Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 42. api.js import axios from 'axios'; const api = axios.create({ baseURL: 'https://api.reactnativetesting.io', // other config }); export default api; Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 43. api.mock.js const api = { get() { return Promise.resolve({ data: [ {id: 1, name: 'Widget 1'}, {id: 2, name: 'Widget 2'}, ] }); }, // ... }; export default api; Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 44. Configure metro.config.js — When flag is set, prefer .mock.js extension when present — Exact code may differ if you've modified metro.config.js for other reasons — E.g. using react-native-svg-transformer — See reactnativetesting.io/e2e/external-services Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 45. package.json "start": "react-native start", +"start:mock": "MOCK_API=true npm run start", "test": "jest" Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 46. For Windows support "start": "react-native start", +"start:mock": "cross-env MOCK_API=true npm run start", "test": "jest" Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 47. Questions? Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 48. 3. How Much to Test with Detox Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 49. To the code! Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 50. Types of Detox Test (not rigid categories) — Boot test — Play-around test — The most important moneymaking feature, happy path flow — Secondary feature happy paths Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 51. Factors — Flake — Test speed — Ease of writing Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 52. Types of Detox Test (not rigid categories) — Boot test — Play-around test — The most important moneymaking feature, happy path flow — Secondary feature happy paths Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 53. Questions? Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 54. 4. Detox on CI Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 55. CI for native mobile apps is hard Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 56. 1. Variations between CI Platforms Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 57. 2. Dependent on details of specific versions On GitHub Actions, Detox works for me on macos-12 and times out on macos-13 Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 58. 3. Slow Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 59. 4. Expensive if you pay by the hour Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 60. 5. If you have a suite that passes on developer machines, it's hard to get it all passing on CI at once Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 61. My GitHub Actions Detox CI Setup Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 62. To the YAML! Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 63. name: Detox on: push: branches: - main pull_request: types: [opened, synchronize, reopened] Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 64. jobs: test: runs-on: macos-12 steps: Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 65. - uses: actions/checkout@v4 - uses: actions/setup-node@v3 with: node-version: 18 cache: "yarn" Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 66. - name: Cache Pods dependencies uses: actions/cache@v3 with: path: ios/Pods key: ${{ runner.OS }}-pods-cache-${{ hashFiles('**/ios/Podfile.lock') }} restore-keys: | ${{ runner.OS }}-pods-cache- - name: Install npm dependencies run: yarn install --frozen-lockfile - name: Install iOS dependencies run: npx pod-install Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 67. - name: Install Detox CLI run: | brew tap wix/brew brew install applesimutils npm install -g detox-cli Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 68. - name: Build App for Detox run: detox build -c ios.sim.release - uses: futureware-tech/simulator-action@v2 with: model: "iPhone 14" - name: Run Detox run: detox test -c ios.sim.release Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 69. Recommendation — Pick your potential CI platform — Try to get a boot test passing on CI — If it doesn't work, try another platform Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 70. 5. Local Detox development workflow Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 71. 3 Stages Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 72. Stage 1: Test Existing Features Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 73. Stage 2: Test Features As You Add Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 74. Stage 3: Test-Driven Development Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 75. Getting Better All the Time: How to Escape Bad Code Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 76. To the code! learntdd.in/react-native Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 77. Why TDD? — Thorough test coverage. — Code that is easy to test. — Minimal code. Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 78. 3 Stages 1. Test some existing features 2. Test new features as you add them 3. Test-driven development Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 79. Questions? Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 80. What We Covered Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 81. 1. What kinds of things to test with Detox Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 82. 1. What kinds of things to test with Detox Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 83. 2. Faking the API layer Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 84. 3. How much to test with Detox — Boot test — Play-around test — The most important moneymaking feature, happy path flow — Secondary feature happy paths Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 85. 4. Detox on CI GitHub Actions example config Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 86. 5. Stages of Detox development 1. Test some existing features 2. Test new features as you add them 3. Test-driven development Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 87. What We Covered 1. What kinds of things to test with Detox 2. Faking the API layer 3. How much of your app to test with Detox 4. Detox on CI 5. Local Detox development workflow Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 88. Thanks! Questions? Josh Justice josh.justice@testdouble.com https://rnte.st/london23 Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23
  • 89. Thanks! Josh Justice josh.justice@testdouble.com https://rnte.st/london23 Effective Detox Testing - Josh Justice - React Advanced - 2023-10-25 - https://rnte.st/london23