1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee
react-native-pushy/Example/testHotUpdate/e2e/globalSetup.ts
2023-03-15 23:27:25 +08:00

30 lines
888 B
TypeScript

import { execSync } from 'child_process';
import { pathExists, ensureDir } from 'fs-extra';
import { resolveConfig } from 'detox/internals';
import { globalSetup } from 'detox/runners/jest';
export default async function customGlobalSetup() {
const config = await resolveConfig();
if (config.device.type === 'android.emulator') {
await downloadTestButlerAPK();
}
await globalSetup();
}
async function downloadTestButlerAPK() {
const version = '2.2.1';
const artifactUrl = `https://repo1.maven.org/maven2/com/linkedin/testbutler/test-butler-app/${version}/test-butler-app-${version}.apk`;
const filePath = `cache/test-butler-app.apk`;
await ensureDir('cache');
if (!(await pathExists(filePath))) {
console.log(`\nDownloading Test-Butler APK v${version}...`);
execSync(`curl -f -o ${filePath} ${artifactUrl}`);
}
}
module.exports = customGlobalSetup;