-
-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
107 additions
and
1 deletion.
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 |
---|---|---|
|
@@ -56,7 +56,7 @@ jobs: | |
# with: | ||
# workspace-focus: ${{ env.test_app_package_name }} | ||
|
||
- name: Download Built Native App | ||
- name: Download Built Test Container App | ||
uses: actions/cache/restore@v4 | ||
with: | ||
fail-on-cache-miss: true | ||
|
@@ -100,6 +100,14 @@ jobs: | |
appium > /tmp/appium.log & | ||
sleep 3 | ||
- name: Test | ||
env: | ||
SIMULATOR_UDID: ${{ steps.get-simulator-udid.outputs.simulator_udid }} | ||
TEST_CONTAINER_PATH: ${{ needs.build-ios-test-container-prod.outputs.built-app-path }} | ||
run: | | ||
cd tests/rn-test-container | ||
yarn vitest | ||
- name: Upload Appium Logs | ||
uses: actions/[email protected] | ||
if: ${{ always() }} | ||
|
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,98 @@ | ||
import { beforeAll, describe, expect, inject, it, test } from 'vitest' | ||
import { remote } from 'webdriverio' | ||
import { execSync } from 'node:child_process' | ||
|
||
function getSimulatorUdid() { | ||
if (process.env.SIMULATOR_UDID) { | ||
return process.env.SIMULATOR_UDID | ||
} | ||
|
||
console.warn('No SIMULATOR_UDID provided, trying to find a simulator automatically...') | ||
|
||
try { | ||
const listDevicesOutput = execSync('xcrun simctl list --json devices').toString() | ||
|
||
const devicesData = JSON.parse(listDevicesOutput).devices | ||
|
||
const runtimes = Reflect.ownKeys(devicesData) | ||
|
||
const runtime = runtimes.find((r) => typeof r === 'string' && r.includes('SimRuntime.iOS-18')) | ||
|
||
if (!runtime) { | ||
throw new Error(`No available runtime found from ${JSON.stringify(runtimes)}`) | ||
} | ||
|
||
const device = devicesData[runtime].find((d) => d.name.includes('iPhone 16 Pro')) | ||
|
||
if (!device) { | ||
throw new Error(`No available device found from ${JSON.stringify(devicesData[runtime])}`) | ||
} | ||
|
||
console.info(`Found simulator device ${device.name} with udid ${device.udid}`) | ||
|
||
return device.udid | ||
} catch (error) { | ||
if (error instanceof Error) { | ||
error.message = `Failed to find an available simulator: ${error.message}` | ||
} | ||
|
||
throw error | ||
} | ||
} | ||
|
||
function getWebDriverOpts() { | ||
const capabilities = { | ||
platformName: 'iOS', | ||
'appium:options': { | ||
automationName: 'XCUITest', | ||
|
||
// deviceName: 'iPhone mini 2', | ||
udid: getSimulatorUdid(), | ||
|
||
app: process.env.TEST_CONTAINER_PATH, | ||
// app: '/Users/z/Downloads/ios-test-container-prod.app', | ||
// bundleId: 'host.exp.Exponent', | ||
|
||
// Do not reset the simulator | ||
// noReset: true, | ||
}, | ||
} | ||
|
||
const wdOpts = { | ||
hostname: process.env.APPIUM_HOST || 'localhost', | ||
port: process.env.APPIUM_PORT ? Number.parseInt(process.env.APPIUM_PORT, 10) : 4723, | ||
logLevel: 'info' as const, | ||
capabilities, | ||
} | ||
|
||
return wdOpts | ||
} | ||
|
||
describe('Native Test Test', () => { | ||
test('should pass', () => { | ||
getWebDriverOpts() | ||
expect(true).toBe(true) | ||
}) | ||
|
||
test('hello world', async () => { | ||
const driver = await remote(getWebDriverOpts()) | ||
Check failure on line 78 in tests/rn-test-container/native-test.test.ts
|
||
// console.log(JSON.stringify(driver.commandList)) | ||
// driver.executeScript('mobile: terminateApp', [{ bundleId: 'host.exp.Exponent' }]) | ||
// driver.executeScript('mobile: launchApp', [{ bundleId: 'host.exp.Exponent' }]) | ||
|
||
// const screenShot = await driver.takeScreenshot() | ||
// console.log('screenShot', screenShot) | ||
await driver.saveScreenshot('./screenshot.png') | ||
|
||
// Select with accessibility id | ||
const element = driver.$('~hello-word') | ||
|
||
// expect element to contain text "Hello, World!" | ||
const text = await element.getText() | ||
expect(text).toBe('Hello One!') | ||
|
||
|
||
// const settingsItem = await driver.$('//*[@text="Settings"]'); | ||
// await settingsItem.click(); | ||
}, 10 * 60 * 1000) | ||
}) |