Skip to content

Commit

Permalink
Merge pull request #6 from sabuhiteymurov/config/detox
Browse files Browse the repository at this point in the history
add: configuration for e2e debug tests
  • Loading branch information
sabuhiteymurov authored Aug 28, 2023
2 parents 5fd3e0f + 8f2c874 commit 5f680cc
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 19 deletions.
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ dist/
web-build/

# Native
android
ios
android/
ios/
*.orig.*
*.jks
*.p8
Expand Down Expand Up @@ -80,3 +80,5 @@ bin/
# Detox
artifacts/

*.log

2 changes: 1 addition & 1 deletion .detoxrc.js → detox.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module.exports = {
type: 'android.apk',
build:
'cd android && ./gradlew :app:assembleDebug :app:assembleAndroidTest -DtestBuildType=debug && cd ..',
binaryPath: 'bin/expo-base.apk',
binaryPath: 'android/app/build/outputs/apk/debug/app-debug.apk',
},
'android.release': {
type: 'android.apk',
Expand Down
13 changes: 9 additions & 4 deletions e2e/tests/starter.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
const { openApp } = require('../utils/openApp');
import { by, element, expect } from 'detox';
import { by, element, expect, waitFor } from 'detox';

describe('Example', () => {
describe('User can sign in successfully', () => {
beforeAll(async () => {
await openApp();
});

it('should have welcome screen', async () => {
await expect(element(by.id('home-screen'))).toBeVisible();
it('should open sign in screen', async () => {
await expect(element(by.id('sign-in-screen'))).toBeVisible();
await expect(element(by.id('sign-in-btn'))).toBeVisible();
});

it('should open home screen when signed in', async () => {
await element(by.id('sign-in-btn')).tap().then(async () => await expect(element(by.id('sign-in-screen'))).toBeVisible());
});
});
5 changes: 3 additions & 2 deletions e2e/utils/openApp.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const appConfig = require('../../app.config.ts');
const { resolveConfig } = require('detox/internals');
const appConfig = require('../../app.config.ts');

const platform = device.getPlatform();

Expand Down Expand Up @@ -39,8 +39,9 @@ async function openAppForDebugBuild(platform: string) {
await sleep(3000);
}

// URL should start with `expo+<app-slug>://`
const getDeepLinkUrl = (url: string) =>
`eastestsexample://expo-development-client/?url=${encodeURIComponent(url)}`;
`expo+expo-base://expo-development-client/?url=${encodeURIComponent(url)}`;

const getDevLauncherPackagerUrl = (platform: string) =>
`http://localhost:8081/index.bundle?platform=${platform}&dev=true&minify=false&disableOnboarding=1`;
Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import 'expo-router/entry';
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
{
"name": "expo-base",
"main": "expo-router/entry",
"version": "1.0.0",
"scripts": {
"start": "expo start",
"start -c": "expo start -c",
"prebuild": "expo prebuild",
"android": "expo run:android",
"android:release": "expo run:android --variant Release",
"android:dev-build": "eas build --profile development --platform android",
"android:dev-build:local": "eas build --profile development --platform android --local",
"android:preview": "eas build --profile preview --platform android",
"android:release": "expo run:android --variant Release",
"ios": "expo run:ios",
"ios:release": "expo run:ios --variant Release",
"ios:dev-build": "eas build --profile development --platform ios",
"ios:dev-build:local": "eas build --profile development --platform ios --local",
"ios:preview": "eas build --profile preview --platform ios",
"ios:release": "expo run:ios --variant Release",
"web": "expo start --web",
"typecheck": "tsc",
"test": "jest --watchAll",
"e2e:ios:build": "detox build -c ios.release",
"e2e:ios:test": "detox test -c ios.release",
"e2e:ios": "run-s e2e:ios:*",
"e2e:ios:debug:build": "detox build -c ios.debug",
"e2e:ios:debug:test": "detox test -c ios.debug",
"e2e:android:build": "detox build -c android.release",
"e2e:android:test": "detox test -c android.release",
"e2e:android": "run-s e2e:android:*",
"detox:android:debug:build": "detox build -c android.debug",
"detox:android:debug:test": "detox test -c android.debug --reuse",
"detox:ios:debug:build": "detox build -c ios.debug",
"detox:ios:debug:test": "detox test -c ios.debug"
"e2e:android:debug:build": "detox build -c android.debug",
"e2e:android:debug:test": "detox test -c android.debug --reuse"
},
"jest": {
"preset": "jest-expo"
Expand Down
2 changes: 1 addition & 1 deletion src/screens/SignIn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const SignIn = () => {
return (
<View style={styles.container} testID='sign-in-screen'>
<Text>{t('signIn:title')}</Text>
<Button title={t('signIn:goToDashboard')} onPress={navigateToDashboard} />
<Button title={t('signIn:goToDashboard')} onPress={navigateToDashboard} testID='sign-in-btn' />
</View>
);
};
Expand Down

0 comments on commit 5f680cc

Please sign in to comment.