-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added react native detox framework for e2e automation (#165)
- Loading branch information
1 parent
54f2284
commit 0145a42
Showing
21 changed files
with
499 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/** @type {Detox.DetoxConfig} */ | ||
module.exports = { | ||
testRunner: { | ||
args: { | ||
$0: 'jest', | ||
config: 'detox-tests/e2e/jest.config.js', | ||
}, | ||
jest: { | ||
setupTimeout: 120000, | ||
}, | ||
}, | ||
apps: { | ||
'ios.debug': { | ||
type: 'ios.app', | ||
binaryPath: | ||
'ios/build/Build/Products/Debug-iphonesimulator/HyperSwitch.app', | ||
build: | ||
'xcodebuild -workspace ios/hyperswitch.xcworkspace -scheme hyperswitch -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build', | ||
}, | ||
'ios.release': { | ||
type: 'ios.app', | ||
binaryPath: | ||
'ios/build/Build/Products/Release-iphonesimulator/YOUR_APP.app', | ||
build: | ||
'xcodebuild -workspace ios/YOUR_APP.xcworkspace -scheme YOUR_APP -configuration Release -sdk iphonesimulator -derivedDataPath ios/build', | ||
}, | ||
'android.debug': { | ||
type: 'android.apk', | ||
binaryPath: 'android/demo-app/build/outputs/apk/debug/demo-app-debug.apk', | ||
testBinaryPath: | ||
'android/demo-app/build/outputs/apk/androidTest/debug/demo-app-debug-androidTest.apk', | ||
build: | ||
'cd android ; ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug ; cd -', | ||
reversePorts: [8081], | ||
}, | ||
'android.release': { | ||
type: 'android.apk', | ||
binaryPath: 'android/app/build/outputs/apk/release/app-release.apk', | ||
build: | ||
'cd android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release', | ||
}, | ||
}, | ||
devices: { | ||
simulator: { | ||
type: 'ios.simulator', | ||
device: { | ||
type: 'iPhone 15', | ||
}, | ||
}, | ||
attached: { | ||
type: 'android.attached', | ||
device: { | ||
adbName: '.*', | ||
}, | ||
}, | ||
emulator: { | ||
type: 'android.emulator', | ||
device: { | ||
avdName: 'Pixel_3a_API_34_extension_level_7_arm64-v8a', | ||
}, | ||
}, | ||
ciEmulator: { | ||
type: 'android.emulator', | ||
device: { | ||
avdName: 'Pixel_API_29_AOSP', | ||
}, | ||
}, | ||
}, | ||
configurations: { | ||
'ios.sim.debug': { | ||
device: 'simulator', | ||
app: 'ios.debug', | ||
}, | ||
'ios.sim.release': { | ||
device: 'simulator', | ||
app: 'ios.release', | ||
}, | ||
'android.att.debug': { | ||
device: 'attached', | ||
app: 'android.debug', | ||
}, | ||
'android.att.release': { | ||
device: 'attached', | ||
app: 'android.release', | ||
}, | ||
'android.emu.debug': { | ||
device: 'emulator', | ||
app: 'android.debug', | ||
}, | ||
'android.emu.ci.debug': { | ||
device: 'ciEmulator', | ||
app: 'android.debug', | ||
}, | ||
'android.emu.release': { | ||
device: 'emulator', | ||
app: 'android.release', | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
# .github/workflows/e2e-android.yml | ||
name: e2e-android | ||
on: push | ||
|
||
jobs: | ||
e2e-android: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Free Disk Space | ||
run: | | ||
sudo rm -rf /opt/hostedtoolcache | ||
sudo rm -rf /usr/share/dotnet | ||
sudo rm -rf /opt/ghc | ||
sudo rm -rf "/usr/local/share/boost" | ||
- name: Enable KVM | ||
run: | | ||
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@v3 | ||
with: | ||
node-version: '20' | ||
# cache: 'npm' | ||
# cache-dependency-path: '**/package-lock.json' | ||
|
||
- name: Install dependencies | ||
run: npm install | ||
|
||
- name: Create .env file | ||
run: | | ||
touch .env | ||
echo ${{ secrets.HYPERSWITCH_PUBLISHABLE_KEY }} | ||
echo STATIC_DIR = ./dist >> .env | ||
echo HYPERSWITCH_PUBLISHABLE_KEY = ${{ secrets.HYPERSWITCH_PUBLISHABLE_KEY }}>> .env | ||
echo HYPERSWITCH_SECRET_KEY = ${{ secrets.HYPERSWITCH_SECRET_KEY }}>> .env | ||
echo PROFILE_ID = ${{ secrets.PROFILE_ID }}>> .env | ||
- name: Start server | ||
run: | | ||
nohup node server.js & | ||
- name: Check Server | ||
run: | | ||
curl http://localhost:5252/create-payment-intent | ||
- name: Setup Java | ||
uses: actions/setup-java@v3 | ||
with: | ||
cache: gradle | ||
distribution: temurin | ||
java-version: 17 | ||
|
||
# - name: Cache Detox build | ||
# id: cache-detox-build | ||
# uses: actions/cache@v3 | ||
# with: | ||
# path: android/app/build | ||
# key: ${{ runner.os }}-detox-build | ||
# restore-keys: | | ||
# ${{ runner.os }}-detox-build | ||
|
||
# - name: List branches | ||
# run: | | ||
# cd android | ||
# git fetch --all | ||
# git branch -r | ||
|
||
- name: Checkout Android Repo | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: juspay/hyperswitch-sdk-android | ||
ref: detox-poc | ||
path: android | ||
fetch-depth: 0 | ||
|
||
- name: Check Android branch | ||
run: | | ||
cd android && git branch && cd .. | ||
- name: Generate & Supply JS Bundle to Test APK | ||
run: | | ||
npm run re:start && npm run bundle:android | ||
- name: Detox build | ||
run: cd android && ls && cd .. && npx detox build --configuration android.emu.ci.debug | ||
|
||
- name: Get device name | ||
id: device | ||
run: node -e "console.log('AVD_NAME=' + require('./.detoxrc').devices.ciEmulator.device.avdName)" >> $GITHUB_OUTPUT | ||
|
||
- name: Check Android branch | ||
run: | | ||
cd android && git branch && cd .. | ||
- name: Detox test | ||
uses: reactivecircus/android-emulator-runner@v2 | ||
with: | ||
api-level: 30 | ||
target: default | ||
arch: x86_64 | ||
profile: pixel | ||
avd-name: ${{ steps.device.outputs.AVD_NAME }} | ||
script: npx detox test --configuration android.emu.ci.debug --headless --loglevel trace --record-logs all | ||
|
||
- name: Upload artifacts | ||
if: failure() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: detox-artifacts | ||
path: artifacts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
# .github/workflows/e2e-ios.yml | ||
name: e2e-ios | ||
on: push | ||
|
||
jobs: | ||
e2e-ios: | ||
runs-on: macos-14 | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Checkout iOS Repo | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: juspay/hyperswitch-sdk-ios | ||
ref: main | ||
path: ios | ||
fetch-depth: 0 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '20' | ||
|
||
- name: Dependency Install | ||
run: | | ||
jq 'del(.resolutions) | | ||
del(.dependencies["react-native-hyperswitch-netcetera-3ds"]) | | ||
del(.dependencies["react-native-hyperswitch-scancard"])' package.json > package.json.tmp && | ||
mv package.json.tmp package.json | ||
npm install | ||
- name: Create .env file | ||
run: | | ||
touch .env | ||
echo ${{ secrets.HYPERSWITCH_PUBLISHABLE_KEY }} | ||
echo STATIC_DIR = ./dist >> .env | ||
echo HYPERSWITCH_PUBLISHABLE_KEY = ${{ secrets.HYPERSWITCH_PUBLISHABLE_KEY }}>> .env | ||
echo HYPERSWITCH_SECRET_KEY = ${{ secrets.HYPERSWITCH_SECRET_KEY }}>> .env | ||
echo PROFILE_ID = ${{ secrets.PROFILE_ID }}>> .env | ||
- name: Start server | ||
run: | | ||
nohup node server.js & | ||
- name: Check Server | ||
run: | | ||
curl http://localhost:5252/create-payment-intent | ||
- name: Install macOS dependencies | ||
run: | | ||
brew tap wix/brew | ||
brew install applesimutils | ||
env: | ||
HOMEBREW_NO_AUTO_UPDATE: 1 | ||
HOMEBREW_NO_INSTALL_CLEANUP: 1 | ||
|
||
# - name: Setup Ruby, JRuby and TruffleRuby | ||
# uses: ruby/setup-ruby@v1.204.0 | ||
|
||
# - name: Cache CocoaPods | ||
# id: cache-cocoapods | ||
# uses: actions/cache@v3 | ||
# with: | ||
# path: ios/Pods | ||
# key: ${{ runner.os }}-pods-${{ hashFiles('ios/Podfile.lock') }} | ||
# restore-keys: | | ||
# ${{ runner.os }}-pods- | ||
|
||
- name: Install CocoaPods | ||
run: | | ||
ls | ||
cd ios | ||
ls | ||
pod setup --verbose | ||
sudo gem install cocoapods | ||
pod install | ||
cd .. | ||
- name: Detox rebuild framework cache | ||
run: npx detox rebuild-framework-cache | ||
|
||
- name: Start Rescript | ||
run: | | ||
npm run re:start | ||
- name: Start Metro | ||
run: | | ||
nohup npm run start & | ||
- name: Cache Detox build | ||
id: cache-detox-build | ||
uses: actions/cache@v3 | ||
with: | ||
path: ios/build | ||
key: ${{ runner.os }}-detox-build | ||
restore-keys: | | ||
${{ runner.os }}-detox-build | ||
- name: Detox build | ||
run: npx detox build --configuration ios.sim.debug | ||
|
||
- name: Detox test | ||
run: npx detox test --configuration ios.sim.debug --loglevel trace --record-logs all | ||
|
||
- name: Upload artifacts | ||
if: failure() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: detox-artifacts | ||
path: artifacts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,4 +112,9 @@ hyperswitch-react-native/lib/bs/ | |
#next | ||
.next/ | ||
next-env.d.ts | ||
/out | ||
/out | ||
|
||
#detox | ||
*.log | ||
*.trace.json | ||
*.detox.jsonl |
Submodule android
updated
4 files
+3 −0 | build.gradle | |
+7 −0 | demo-app/build.gradle | |
+30 −0 | demo-app/src/androidTest/java/DetoxTest.java | |
+30 −0 | demo-app/src/main/java/io/hyperswitch/demoapp/DetoxTest.java |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module.exports = { | ||
presets: [ | ||
'@babel/preset-env', // Handles modern JavaScript features like `export` | ||
], | ||
plugins: [ | ||
'@babel/plugin-transform-modules-commonjs', // Transforms ES modules to CommonJS for Jest compatibility | ||
], | ||
}; |
Oops, something went wrong.