1
0
mirror of https://gitcode.com/gh_mirrors/re/react-native-pushy.git synced 2025-10-31 13:23:12 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee

feat: project init

This commit is contained in:
steven
2023-03-15 23:27:25 +08:00
parent 992b17d25a
commit 92675ed37c
43 changed files with 6448 additions and 546 deletions

View File

@@ -0,0 +1,89 @@
import {by, device, element, expect} from 'detox';
describe('测试Native模块的方法', () => {
beforeAll(async () => {
await device.launchApp();
});
it('setLocalHashInfo', async () => {
await element(by.id('testcase')).longPress();
await element(by.id('setLocalHashInfo')).tap();
await element(by.id('submit')).tap();
await expect(element(by.text('done'))).toBeVisible();
await element(by.text('OK')).tap();
});
it('getLocalHashInfo', async () => {
await element(by.id('getLocalHashInfo')).tap();
await element(by.id('submit')).tap();
await expect(element(by.text('done'))).toBeVisible();
await element(by.text('OK')).tap();
});
it('setUuid', async () => {
await element(by.id('setUuid')).tap();
await element(by.id('submit')).tap();
await expect(element(by.text('done'))).toBeVisible();
await element(by.text('OK')).tap();
});
it('setBlockUpdate', async () => {
await element(by.id('setBlockUpdate')).tap();
await element(by.id('submit')).tap();
await expect(element(by.text('done'))).toBeVisible();
await element(by.text('OK')).tap();
});
it('reloadUpdate', async () => {
await element(by.id('reloadUpdate')).tap();
await element(by.id('submit')).tap();
await expect(element(by.text('刚刚更新失败了,版本被回滚.'))).toBeVisible();
await element(by.text('OK')).tap();
});
it('setNeedUpdate', async () => {
await element(by.id('testcase')).longPress();
await element(by.id('setNeedUpdate')).tap();
await element(by.id('submit')).tap();
await expect(element(by.text('done'))).toBeVisible();
await element(by.text('OK')).tap();
});
it('markSuccess', async () => {
await element(by.id('markSuccess')).tap();
await element(by.id('submit')).tap();
await expect(element(by.text('done'))).toBeVisible();
await element(by.text('OK')).tap();
});
it('downloadPatchFromPpk', async () => {
await element(by.id('downloadPatchFromPpk')).tap();
await element(by.id('submit')).tap();
await expect(element(by.text('failed to open zip file'))).toBeVisible();
await element(by.text('OK')).tap();
});
it('downloadPatchFromPackage', async () => {
await element(by.id('downloadPatchFromPackage')).tap();
await element(by.id('submit')).tap();
await expect(element(by.text('failed to open zip file'))).toBeVisible();
await element(by.text('OK')).tap();
});
it('downloadFullUpdate', async () => {
await element(by.id('downloadFullUpdate')).tap();
await element(by.id('submit')).tap();
await expect(element(by.text('failed to open zip file'))).toBeVisible();
await element(by.text('OK')).tap();
});
if (device.getPlatform() === 'android') {
it('downloadAndInstallApk', async () => {
await element(by.id('testcase')).longPress();
await element(by.id('downloadAndInstallApk')).tap();
await element(by.id('submit')).tap();
await expect(element(by.text('failed to open zip file'))).toBeVisible();
await element(by.text('OK')).tap();
});
}
});

View File

@@ -0,0 +1,29 @@
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;

View File

@@ -0,0 +1,16 @@
/** @type {import('jest').Config} */
module.exports = {
maxWorkers: 1,
globalSetup: './globalSetup.ts',
globalTeardown: 'detox/runners/jest/globalTeardown',
testEnvironment: 'detox/runners/jest/testEnvironment',
setupFilesAfterEnv: ['./setup.ts'],
testRunner: 'jest-circus/runner',
testTimeout: 120000,
testMatch: ['**/*.test.ts'],
transform: {
'\\.tsx?$': 'ts-jest',
},
reporters: ['detox/runners/jest/reporter'],
verbose: true,
};

View File

@@ -0,0 +1,5 @@
import { device } from 'detox';
beforeAll(async () => {
await device.launchApp();
});