Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion .github/workflow-scripts/__tests__/maestro-ios-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jest.mock('fs', () => ({
const childProcess = require('child_process');
const fs = require('fs');

const {executeFlows} = require('../maestro-ios');
const {executeFlows, findAvailableSimulator} = require('../maestro-ios');

describe('Maestro iOS runner', () => {
beforeEach(() => {
Expand Down Expand Up @@ -59,4 +59,23 @@ describe('Maestro iOS runner', () => {
expect(call[0]).toContain('test "flow.yml"');
}
});

it('selects an iPhone Pro simulator from the latest runtime', () => {
childProcess.execSync.mockReturnValue(
JSON.stringify({
devices: {
'iOS 18.5': [{name: 'iPhone 16 Pro', udid: 'old-pro'}],
'iOS 26.5': [
{name: 'iPhone 17 Pro Max', udid: 'new-pro-max'},
{name: 'iPhone 17 Pro', udid: 'new-pro'},
],
},
}),
);

expect(findAvailableSimulator()).toEqual({
name: 'iPhone 17 Pro',
udid: 'new-pro',
});
});
});
40 changes: 24 additions & 16 deletions .github/workflow-scripts/maestro-ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,26 @@ node maestro-android.js <path to app> <app_id> <maestro_flow> <flavor> <working_

const MAX_ATTEMPTS = 5;

function launchSimulator(simulatorName) {
console.log(`Launching simulator ${simulatorName}`);
function findAvailableSimulator() {
const output = childProcess.execSync(
'xcrun simctl list devices available -j',
);
const devices = Object.values(JSON.parse(String(output)).devices)
.flat()
.reverse();
const simulator = devices.find(device => /^iPhone .* Pro$/.test(device.name));

if (simulator == null) {
throw new Error('Unable to find an available iPhone Pro simulator');
}

return simulator;
}

function launchSimulator(simulator) {
console.log(`Launching simulator ${simulator.name} (${simulator.udid})`);
try {
childProcess.execSync(`xcrun simctl boot "${simulatorName}"`);
childProcess.execSync(`xcrun simctl boot "${simulator.udid}"`);
} catch (error) {
if (
!error.message.includes('Unable to boot device in current state: Booted')
Expand All @@ -43,14 +59,6 @@ function installAppOnSimulator(appPath) {
childProcess.execSync(`xcrun simctl install booted "${appPath}"`);
}

function extractSimulatorUDID() {
console.log('Retrieving device UDID');
const command = `xcrun simctl list devices booted -j | jq -r '[.devices[]] | add | first | .udid'`;
const udid = String(childProcess.execSync(command)).trim();
console.log(`UDID is ${udid}`);
return udid;
}

function bringSimulatorInForeground() {
console.log('Bringing simulator in foreground');
childProcess.execSync('open -a simulator');
Expand Down Expand Up @@ -166,13 +174,12 @@ async function main(args = process.argv.slice(2)) {
console.info(`WORKING_DIRECTORY: ${workingDirectory}`);
console.info('==============================\n');

const simulatorName = 'iPhone 16 Pro';
launchSimulator(simulatorName);
const simulator = findAvailableSimulator();
launchSimulator(simulator);
installAppOnSimulator(appPath);
const udid = extractSimulatorUDID();
bringSimulatorInForeground();
await launchAppOnSimulator(appId, udid, isDebug);
executeFlows(appId, udid, maestroFlow, jsengine);
await launchAppOnSimulator(appId, simulator.udid, isDebug);
executeFlows(appId, simulator.udid, maestroFlow, jsengine);
console.log('Test finished');
}

Expand All @@ -182,4 +189,5 @@ if (require.main === module) {

module.exports = {
executeFlows,
findAvailableSimulator,
};
4 changes: 1 addition & 3 deletions .github/workflows/e2e-ios-rntester.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ on:

jobs:
test:
runs-on: macos-15-large
runs-on: macos-26-large
outputs:
status: ${{ steps.report-status.outputs.status }}
strategy:
Expand All @@ -35,8 +35,6 @@ jobs:
path: /tmp/RNTesterBuild/RNTester.app
- name: Check downloaded folder content
run: ls -lR /tmp/RNTesterBuild
- name: Setup xcode
uses: ./.github/actions/setup-xcode
- name: Run E2E Tests
id: run-tests
continue-on-error: true
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/e2e-ios-templateapp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ on:

jobs:
test:
runs-on: macos-15-large
runs-on: macos-26-large
outputs:
status: ${{ steps.report-status.outputs.status }}
strategy:
Expand All @@ -26,8 +26,6 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup xcode
uses: ./.github/actions/setup-xcode
- name: Setup node.js
uses: ./.github/actions/setup-node
- name: Run yarn
Expand Down
Loading