Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e2e tests with detox #326

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions .github/workflows/e2e-android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# https://remarkablemark.org/blog/2023/02/18/how-to-run-react-native-detox-tests-on-github-actions/

name: e2e-android
on:
pull_request:
types: [closed]
branches: [main]

jobs:
e2e-android:
runs-on: ubuntu-latest
steps:

- name: Checkout repository
uses: actions/checkout@v4

# - name: Enable KVM
# run: |
# mkdir -p /etc/udev/rules.d
# echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
# sudo udevadm control --reload-rules
# sudo udevadm trigger --name-match=kvm

- name: Setup Node.js
uses: actions/setup-node@v4
with:
cache: 'npm'
node-version: '18'

- name: Install dependencies
run: npm install

- name: Setup Java
uses: actions/setup-java@v4
with:
# cache: 'gradle'
distribution: 'temurin'
java-version: '17'

# - name: Gradle cache
# uses: gradle/actions/setup-gradle@v3

# - name: AVD cache
# uses: actions/cache@v4
# id: avd-cache
# with:
# path: |
# ~/.android/avd/*
# ~/.android/adb*
# key: avd-${{ env.API_LEVEL }}

# - name: Create AVD and generate snapshot for caching
# if: steps.avd-cache.outputs.cache-hit != 'true'
# uses: reactivecircus/android-emulator-runner@v2
# with:
# api-level: ${{ env.API_LEVEL }}
# arch: ${{ env.ARCH }}
# disable-animations: false
# emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
# force-avd-creation: false
# script: echo 'Generated AVD snapshot for caching.'

- name: Setup Android SDK
uses: android-actions/setup-android@v3

- name: Android prebuild
run: npx expo prebuild --platform android --clean

# - name: Cache Detox build
# id: cache-detox-build
# uses: actions/cache@v4
# with:
# path: android/app/build
# key: ${{ runner.os }}-detox-build
# restore-keys: |
# ${{ runner.os }}-detox-build

- name: Detox build
run: npm run detox:build:android

- name: Get device name
id: device-name
run: echo "::set-output name=DEVICE_NAME::$(node -e "console.log(require('./detox.config.js').devices.emulator.device.avdName)")"

- name: Detox test
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 34
arch: x86_64
avd-name: ${{ steps.device-name.outputs.DEVICE_NAME }}
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
script: npm run detox:test:android:ci
4 changes: 3 additions & 1 deletion .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:

strategy:
matrix:
node-version: [18.x, 20.x, 21.x]
node-version: [21.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
Expand All @@ -39,3 +39,5 @@ jobs:
uses: codecov/codecov-action@v3
with:
token: ${{secrets.CODECOV_TOKEN}}

# 18.x, 20.x,
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,8 @@ web-build/
.*.env.*
.env

# Detox
artifacts/

# Diagnostic reports (https://nodejs.org/api/report.html)
report/
3 changes: 2 additions & 1 deletion config/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ const config: ExpoConfig = {
dsn: process?.env?.SENTRY_DSN, // || 'sentry dsn, or use the `SENTRY_DSN` environment variable',
authToken: process?.env?.SENTRY_AUTH_TOKEN, // || 'sentry auth token, or use the `SENTRY_AUTH_TOKEN` environment variable',
}
]
],
'@config-plugins/detox'
],
ios: {
supportsTablet: false,
Expand Down
2 changes: 1 addition & 1 deletion config/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default (): JestConfigWithTsJest => ({
}]
},
resolver: 'ts-jest-resolver',
testRegex: 'test/.*\\.(test|spec)?\\.(ts|tsx)$',
testRegex: 'test/(?!e2e/).*\\.(test|spec)?\\.(ts|tsx)$',
// moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
preset: 'jest-expo',
transformIgnorePatterns: [
Expand Down
57 changes: 57 additions & 0 deletions detox.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/** @type {Detox.DetoxConfig} */
module.exports = {
logger: {
level: process.env.CI ? 'debug' : undefined
},
testRunner: {
args: {
$0: 'jest',
config: './test/e2e/jest.config.ts',
_: ['e2e']
}
},
artifacts: {
rootDir: '.artifacts',
plugins: {
log: process.env.CI ? 'failing' : undefined,
screenshot: 'failing'
}
},
apps: {
'ios.release': {
type: 'ios.app',
build:
'xcodebuild -workspace ios/eastestsexample.xcworkspace -scheme eastestsexample -configuration Release -sdk iphonesimulator -arch x86_64 -derivedDataPath ios/build',
binaryPath: 'ios/build/Build/Products/Release-iphonesimulator/eastestsexample.app'
},
'android.release': {
type: 'android.apk',
build: 'cd android && ./gradlew clean :app:assembleRelease :app:assembleAndroidTest -DtestBuildType=release && cd ..',
binaryPath: 'android/app/build/outputs/apk/release/app-release.apk'
},
},
devices: {
simulator: {
type: 'ios.simulator',
device: {
type: 'iPhone 14'
}
},
emulator: {
type: 'android.emulator',
device: {
avdName: 'Pixel_7_Pro_API_34'
}
}
},
configurations: {
'ios.release': {
device: 'simulator',
app: 'ios.release'
},
'android.emu.release': {
device: 'emulator',
app: 'android.release'
}
}
}
Loading
Loading