├── .watchmanconfig ├── e2e ├── mocha.opts ├── init.js └── firstTest.spec.js ├── .babelrc ├── .gitignore ├── example.gif ├── app.json ├── setup.sh ├── package.json ├── README.md └── App.js /.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /e2e/mocha.opts: -------------------------------------------------------------------------------- 1 | --recursive --timeout 1200000 --bail 2 | -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["babel-preset-expo"] 3 | } 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/**/* 2 | .expo/* 3 | npm-debug.* 4 | bin/ 5 | -------------------------------------------------------------------------------- /example.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/expo/with-detox-tests/HEAD/example.gif -------------------------------------------------------------------------------- /e2e/init.js: -------------------------------------------------------------------------------- 1 | require('babel-polyfill'); 2 | const detox = require('detox'); 3 | const config = require('../package.json').detox; 4 | 5 | before(async () => { 6 | await detox.init(config); 7 | }); 8 | 9 | after(async () => { 10 | await detox.cleanup(); 11 | }); 12 | -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "expo": { 3 | "name": "with-detox-tests", 4 | "description": "Demonstrates integration of the Detox gray box end-to-end testing library with Expo", 5 | "slug": "with-detox-tests", 6 | "privacy": "unlisted", 7 | "sdkVersion": "31.0.0", 8 | "version": "1.0.0", 9 | "orientation": "portrait" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | # query expo.io to find most recent ipaUrl 4 | IPA_URL=`curl https://expo.io/--/api/v2/versions | python -c 'import sys, json; print json.load(sys.stdin)["iosUrl"]'` 5 | 6 | # download tar.gz 7 | TMP_PATH=/tmp/exponent.tar.gz 8 | wget -O $TMP_PATH $IPA_URL 9 | 10 | # recursively make app dir 11 | APP_PATH=bin/Exponent.app 12 | mkdir -p $APP_PATH 13 | 14 | # unzip tar.gz into APP_PATH 15 | tar -C $APP_PATH -xzf $TMP_PATH 16 | -------------------------------------------------------------------------------- /e2e/firstTest.spec.js: -------------------------------------------------------------------------------- 1 | const { reloadApp } = require('detox-expo-helpers'); 2 | 3 | describe('Example', () => { 4 | beforeEach(async () => { 5 | await reloadApp(); 6 | }); 7 | 8 | it('should have welcome screen', async () => { 9 | await expect(element(by.id('welcome'))).toBeVisible(); 10 | }); 11 | 12 | it('should show hello screen after tap', async () => { 13 | await element(by.id('hello_button')).tap(); 14 | await expect(element(by.label('Hello!!!'))).toBeVisible(); 15 | }); 16 | 17 | it('should show world screen after tap', async () => { 18 | await element(by.id('world_button')).tap(); 19 | await expect(element(by.label('World!!!'))).toBeVisible(); 20 | }); 21 | }); 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "detox-testing", 3 | "version": "0.0.0", 4 | "description": "Hello Expo!", 5 | "author": null, 6 | "private": true, 7 | "main": "node_modules/expo/AppEntry.js", 8 | "scripts": { 9 | "e2e": "detox test --configuration ios.sim" 10 | }, 11 | "dependencies": { 12 | "expo": "^31.0.4", 13 | "react": "16.5.0", 14 | "react-native": "https://github.com/expo/react-native/archive/sdk-31.0.1.tar.gz" 15 | }, 16 | "devDependencies": { 17 | "babel-polyfill": "^6.26.0", 18 | "detox": "^9.0.6", 19 | "detox-expo-helpers": "^0.6.0", 20 | "expo-detox-hook": "^1.0.10", 21 | "mocha": "^3.5.0" 22 | }, 23 | "detox": { 24 | "configurations": { 25 | "ios.sim": { 26 | "binaryPath": "bin/Exponent.app", 27 | "type": "ios.simulator", 28 | "name": "iPhone 7" 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 🚨 Attention! 🚨 2 | 3 | This repository is no longer maintained. We recommend that you refer to the following repository instead: https://github.com/yaron1m/expo-detox-typescript-example 4 | 5 |
6 | 7 | # Archived documentation 8 | 9 | ## with-detox-tests 10 | 11 | Demonstrates integration of the Detox gray box end-to-end testing library with Expo. Uses [detox](https://github.com/wix/Detox) 9.0.6+, [detox-expo-helpers](https://github.com/expo/detox-expo-helpers) and [expo-detox-hooks](https://github.com/expo/detox-tools). 12 | 13 | ![](https://raw.githubusercontent.com/expo/with-detox-tests/master/example.gif) 14 | 15 | ### Try it out 16 | 17 | 1. [Install dependencies](https://github.com/wix/detox/blob/master/docs/Introduction.GettingStarted.md#step-1-install-dependencies) (only follow Step 1 from this guide for now, the rest is already done in this project) 18 | 2. Run `./setup.sh`. This should grab the latest [Expo app](https://expo.io/tools) and place it inside `bin/` 19 | 3. Start the packager: `expo start` (if you don't have `expo` installed, `yarn global add expo`). 20 | 4. `npm run e2e` 21 | -------------------------------------------------------------------------------- /App.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { StyleSheet, Text, TouchableOpacity, View } from 'react-native'; 3 | 4 | export default class App extends Component { 5 | state = { 6 | greeting: undefined, 7 | }; 8 | 9 | render() { 10 | if (this.state.greeting) return this.renderAfterButton(); 11 | return ( 12 | 20 | Welcome 21 | 24 | Say Hello 25 | 26 | 29 | Say World 30 | 31 | 32 | ); 33 | } 34 | renderAfterButton() { 35 | return ( 36 | 43 | {this.state.greeting}!!! 44 | 45 | ); 46 | } 47 | 48 | onButtonPress(greeting) { 49 | this.setState({ 50 | greeting: greeting, 51 | }); 52 | } 53 | } 54 | 55 | const styles = StyleSheet.create({ 56 | container: { 57 | flex: 1, 58 | backgroundColor: '#fff', 59 | alignItems: 'center', 60 | justifyContent: 'center', 61 | }, 62 | }); 63 | --------------------------------------------------------------------------------