Skip to content

Commit

Permalink
ci: upgrade detox
Browse files Browse the repository at this point in the history
  • Loading branch information
Salakar committed Jul 9, 2024
1 parent b872233 commit 7ee88cf
Show file tree
Hide file tree
Showing 20 changed files with 505 additions and 376 deletions.
10 changes: 0 additions & 10 deletions .github/workflows/scripts/adb_all_emulators.sh

This file was deleted.

9 changes: 8 additions & 1 deletion .github/workflows/tests_e2e_ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
name: iOS
runs-on: macos-14-xlarge
# TODO matrix across APIs, at least 11 and 15 (lowest to highest)
timeout-minutes: 100
timeout-minutes: 60
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
steps:
Expand Down Expand Up @@ -129,6 +129,13 @@ jobs:
- name: Start Firestore Emulator
run: yarn tests:emulator:start-ci

# https://bitrise.io/blog/post/xcode-15-performance-regressions
- name: Install yeetd
run: |
wget https://github.com/biscuitehh/yeetd/releases/download/1.0/yeetd-normal.pkg
sudo installer -pkg yeetd-normal.pkg -target /
yeetd &
- name: Install brew utilities
uses: nick-fields/retry@v3
with:
Expand Down
11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,13 @@
"tests:android:build": "cd tests && yarn detox build --configuration android.emu.debug",
"tests:android:build:windows": "cd tests && yarn detox build --configuration android.emu.debug.windows",
"tests:android:build-release": "cd tests && yarn detox build --configuration android.emu.release",
"tests:android:test": "yarn tests:android:emulator:forward && cd tests && yarn detox test --configuration android.emu.debug",
"tests:android:test": "cd tests && yarn detox test --configuration android.emu.debug",
"tests:android:test:windows": "cd tests && yarn detox test --configuration android.emu.debug",
"tests:android:test:debug": "yarn tests:android:emulator:forward && cd tests && yarn detox test --configuration android.emu.debug --inspect",
"tests:android:test-reuse": "yarn tests:android:emulator:forward && cd tests && yarn detox test --configuration android.emu.debug --reuse",
"tests:android:test-cover": "yarn tests:android:emulator:forward && cd tests && yarn detox test --configuration android.emu.debug --loglevel verbose",
"tests:android:test-cover-reuse": "yarn tests:android:emulator:forward && cd tests && yarn detox test --configuration android.emu.debug --reuse",
"tests:android:test:debug": "cd tests && yarn detox test --configuration android.emu.debug --inspect",
"tests:android:test-reuse": "cd tests && yarn detox test --configuration android.emu.debug --reuse",
"tests:android:test-cover": "cd tests && yarn detox test --configuration android.emu.debug --loglevel verbose",
"tests:android:test-cover-reuse": "cd tests && yarn detox test --configuration android.emu.debug --reuse",
"tests:android:test:jacoco-report": "cd tests/android && ./gradlew jacocoAndroidTestReport",
"tests:android:emulator:forward": ".github/workflows/scripts/adb_all_emulators.sh 'reverse tcp:8081 tcp:8081' && .github/workflows/scripts/adb_all_emulators.sh 'reverse tcp:8090 tcp:8090' && .github/workflows/scripts/adb_all_emulators.sh 'reverse tcp:8080 tcp:8080' && .github/workflows/scripts/adb_all_emulators.sh 'reverse tcp:9099 tcp:9099' && .github/workflows/scripts/adb_all_emulators.sh 'reverse tcp:9000 tcp:9000' && .github/workflows/scripts/adb_all_emulators.sh 'reverse tcp:9199 tcp:9199'",
"tests:ios:build": "cd tests && yarn detox build --configuration ios.sim.debug",
"tests:ios:build-release": "cd tests && yarn detox build --configuration ios.sim.release",
"tests:ios:test": "cd tests && SIMCTL_CHILD_GULGeneratedClassDisposeDisabled=1 yarn detox test --configuration ios.sim.debug --loglevel warn",
Expand Down
4 changes: 3 additions & 1 deletion packages/app-check/e2e/appcheck.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*
*/

import { Base64 } from '@react-native-firebase/app/lib/common';

function decodeJWT(token) {
// Split the token into its parts
const parts = token.split('.');
Expand All @@ -40,7 +42,7 @@ function decodeJWT(token) {
}

return decodeURIComponent(
atob(base64)
Base64.atob(base64)
.split('')
.map(function (c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
Expand Down
9 changes: 6 additions & 3 deletions packages/auth/e2e/phone.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ describe('auth() => Phone', function () {
});
});

describe('verifyPhoneNumber', function () {
// TODO these are now heavily rate limited by Firebase so they fail often
// or take minutes to complete each test.
xdescribe('verifyPhoneNumber', function () {
it('successfully verifies', async function () {
const testPhone = getRandomPhoneNumber();
const confirmResult = await firebase.auth().signInWithPhoneNumber(testPhone);
Expand Down Expand Up @@ -254,8 +256,9 @@ describe('auth() => Phone', function () {
});

// Note: verifyPhoneNumber is not available in the Firebase v9 API. The following tests need to be updated to use the new API.

describe('verifyPhoneNumber', function () {
// TODO these are now heavily rate limited by Firebase so they fail often
// or take minutes to complete each test.
xdescribe('verifyPhoneNumber', function () {
it('successfully verifies', async function () {
const { getAuth, signInWithPhoneNumber } = authModular;

Expand Down
4 changes: 3 additions & 1 deletion packages/installations/e2e/installations.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*
*/

import { Base64 } from '@react-native-firebase/app/lib/common';

function decodeJWT(token) {
// Split the token into its parts
const parts = token.split('.');
Expand All @@ -40,7 +42,7 @@ function decodeJWT(token) {
}

return decodeURIComponent(
atob(base64)
Base64.atob(base64)
.split('')
.map(function (c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
Expand Down
88 changes: 88 additions & 0 deletions tests/.detoxrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/** @type {Detox.DetoxConfig} */
module.exports = {
testRunner: {
args: {
'$0': 'jest',
config: 'e2e/jest.config.js'
},
jest: {
setupTimeout: 120000
}
},
apps: {
'ios.debug': {
type: 'ios.app',
binaryPath: 'ios/build/Build/Products/Debug-iphonesimulator/testing.app',
build: 'set -o pipefail && xcodebuild VALID_ARCHS="`uname -m`" CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ -workspace ios/testing.xcworkspace -scheme testing -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build | xcbeautify'
},
'ios.release': {
type: 'ios.app',
binaryPath: 'ios/build/Build/Products/Release-iphonesimulator/testing.app',
build: 'export RCT_NO_LAUNCH_PACKAGER=true && set -o pipefail | xcodebuild CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ -workspace ios/testing.xcworkspace -scheme testing -configuration Release -sdk iphonesimulator -derivedDataPath ios/build | xcbeautify'
},
'android.debug': {
type: 'android.apk',
binaryPath: 'android/app/build/outputs/apk/debug/app-debug.apk',
build: 'cd android && ./gradlew assembleDebug assembleAndroidTest lintDebug -DtestBuildType=debug && cd ..',
reversePorts: [
8080,
8081,
8090,
9000,
9099,
9199
]
},
'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: 'TestingAVD'
}
}
},
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.release': {
device: 'emulator',
app: 'android.release'
}
}
};
13 changes: 9 additions & 4 deletions tests/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ dependencies {
implementation("androidx.swiperefreshlayout:swiperefreshlayout:${rootProject.ext.swiperefreshlayoutVersion}")
implementation("androidx.vectordrawable:vectordrawable-animated:${rootProject.ext.vectordrawableVersion}")
implementation("androidx.vectordrawable:vectordrawable:${rootProject.ext.vectordrawableVersion}")
// Workaround build error relating to "barrierMargin" attribute not found
implementation "androidx.constraintlayout:constraintlayout:2.2.0-alpha13"

if (hermesEnabled.toBoolean()) {
implementation("com.facebook.react:hermes-android")
Expand All @@ -165,11 +167,14 @@ dependencies {
/* ------------------------
* TESTING SDKS/LIBRARIES
* ------------------------ */
androidTestImplementation(project(path: ':detox'))
androidTestImplementation(project(path: ':detox')) {
// Workaround java.lang.NoSuchMethodError: No static method registerDefaultInstance(Ljava/lang/Class;Lcom/google/protobuf/GeneratedMessageLite;)V in class Lcom/google/protobuf/GeneratedMessageLite;
exclude module: "protobuf-lite"
}

def firebaseBomVersion = new JsonSlurper().parseText(new File('../node_modules/@react-native-firebase/app/package.json').text).sdkVersions.android.firebase
androidTestImplementation platform("com.google.firebase:firebase-bom:${firebaseBomVersion}")
androidTestImplementation "com.google.firebase:firebase-appcheck-debug-testing"
def firebaseBomVersion = new JsonSlurper().parseText(new File('../node_modules/@react-native-firebase/app/package.json').text).sdkVersions.android.firebase
androidTestImplementation platform("com.google.firebase:firebase-bom:${firebaseBomVersion}")
androidTestImplementation "com.google.firebase:firebase-appcheck-debug-testing"
}

apply from: file('../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle'); applyNativeModulesAppBuildGradle(project)
2 changes: 1 addition & 1 deletion tests/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ buildscript {
ext.appCompatVersion = '1.7.0' // this maps to androidx.appcompat https://developer.android.com/jetpack/androidx/releases/appcompat
ext.supportVersion = ext.supportLibVersion
ext.frescoVersion = '3.2.0' // https://github.com/facebook/fresco/releases
ext.fragmentVersion = '1.8.0' // https://developer.android.com/jetpack/androidx/releases/fragment
ext.fragmentVersion = '1.8.1' // https://developer.android.com/jetpack/androidx/releases/fragment
ext.vectordrawableVersion = '1.2.0' // https://developer.android.com/jetpack/androidx/releases/vectordrawable
ext.androidxAnnotationVersion = '1.8.0' // https://developer.android.com/jetpack/androidx/releases/annotation
ext.googlePlayServicesLocationVersion = '21.3.0' // https://developers.google.com/android/guides/setup
Expand Down
3 changes: 2 additions & 1 deletion tests/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ function loadTests(_) {
await Utils.sleep(5000 * retry);
} else {
// Allow time for things to settle between tests.
await Utils.sleep(100);
await Utils.sleep(50);

}
});

Expand Down
17 changes: 0 additions & 17 deletions tests/e2e/.mocharc.js

This file was deleted.

52 changes: 17 additions & 35 deletions tests/e2e/init.js → tests/e2e/firebase.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,44 +15,13 @@
* limitations under the License.
*
*/
const detox = require('detox');
const { execSync, spawn } = require('child_process');

const { detox: config } = require('../package.json');

config.configurations['android.emu.debug'].device.avdName =
process.env.ANDROID_AVD_NAME || config.configurations['android.emu.debug'].device.avdName;

process.on('unhandledRejection', err => {
console.error(err);
process.exit(1);
});

before(async function () {
await detox.init(config);
});

beforeEach(async function beforeEachTest() {
const retry = this.currentTest.currentRetry();
if (retry > 0) {
if (retry === 1) {
console.log('');
console.warn('⚠️ Suite failed. Relaunching application and trying again.');
}
if (retry > 1) {
console.warn(` 🔴 Suite Retry #${retry - 1} failed...`);
}
console.warn(`️ -> Retrying suite in ${5 * retry} seconds ... (${retry})`);
await new Promise(resolve => setTimeout(resolve, 5000 * retry));
}
await device.launchApp({ newInstance: true, delete: true });
// Give the app time to settle before starting the tests.
await new Promise(resolve => setTimeout(resolve, 1000));
});

describe('Jet Tests', () => {
jest.retryTimes(3, { logErrorsBeforeRetry: true });

it('runs all tests', async () => {
return new Promise((resolve, reject) => {
return new Promise(async (resolve, reject) => {
const platform = detox.device.getPlatform();
const jetProcess = spawn('yarn', ['jet', `--target=${platform}`, '--coverage'], {
stdio: ['ignore', 'inherit', 'inherit'],
Expand All @@ -63,11 +32,24 @@ describe('Jet Tests', () => {
}
reject(new Error(`Jet tests failed!`));
});
await device.launchApp({
newInstance: true,
delete: true,
launchArgs: { detoxURLBlacklistRegex: `.*` },
});
});
});
});

after(async function () {
beforeAll(async function () {
// Nothing to do here.
});

beforeEach(async function () {
// Nothing to do here.
});

afterAll(async function () {
console.log(' ✨ Tests Complete ✨ ');
const isAndroid = detox.device.getPlatform() === 'android';
const deviceId = detox.device.id;
Expand Down
12 changes: 12 additions & 0 deletions tests/e2e/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/** @type {import('@jest/types').Config.InitialOptions} */
module.exports = {
rootDir: '..',
testMatch: ['<rootDir>/e2e/**/*.test.js'],
testTimeout: 1500000,
maxWorkers: 1,
globalSetup: 'detox/runners/jest/globalSetup',
globalTeardown: 'detox/runners/jest/globalTeardown',
reporters: ['detox/runners/jest/reporter'],
testEnvironment: 'detox/runners/jest/testEnvironment',
verbose: true,
};
10 changes: 5 additions & 5 deletions tests/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ import 'should-sinon';
import 'should';
import shouldMatchers from 'should';

// Set debugging before importing any RNFB packages.
global.RNFBDebug = true;
// Toggle this to see bridge and event debug logs
// specific to the React Native Firebase packages
global.RNFBDebug = false;

// RNFB packages.
import '@react-native-firebase/analytics';
Expand Down Expand Up @@ -414,6 +415,5 @@ global.jet = {
},
};

// TODO
global.isCI = false;
// global.isCI = !!process.env.CI;
// TODO toggle this correct in CI only.
global.isCI = true;
2 changes: 1 addition & 1 deletion tests/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1779,6 +1779,6 @@ SPEC CHECKSUMS:
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
Yoga: 64cd2a583ead952b0315d5135bf39e053ae9be70

PODFILE CHECKSUM: da6a0b875968b947599691ee4f009d84f87a83ed
PODFILE CHECKSUM: 95dd7da90f1ff7fdc1017f409737e31d23b1c46a

COCOAPODS: 1.15.2
3 changes: 0 additions & 3 deletions tests/metro.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ const config = {
},
),
},
server: {
runInspectorProxy: !process.env.CI,
},
transformer: {
unstable_allowRequireContext: true,
getTransformOptions: async () => ({
Expand Down
Loading

0 comments on commit 7ee88cf

Please sign in to comment.