Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RNMobile] Add iOS platform version to iOS local e2e capabilities #29715

Merged
merged 7 commits into from
Mar 12, 2021
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const ios = {
exports.iosLocal = {
...ios,
deviceName: 'iPhone 11',
wdaLaunchTimeout: 240000,
};

exports.iosServer = {
Expand Down
34 changes: 34 additions & 0 deletions packages/react-native-editor/__device-tests__/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,18 @@ const isLocalEnvironment = () => {
return testEnvironment.toLowerCase() === 'local';
};

const getIOSPlatformVersions = () => {
const { runtimes = [] } = JSON.parse(
childProcess.execSync( 'xcrun simctl list runtimes --json' ).toString()
);

return runtimes
.reverse()
.filter(
( { name, isAvailable } ) => name.startsWith( 'iOS' ) && isAvailable
);
};

// Initialises the driver and desired capabilities for appium
const setupDriver = async () => {
const branch = process.env.CIRCLE_BRANCH || '';
Expand Down Expand Up @@ -105,6 +117,28 @@ const setupDriver = async () => {
desiredCaps.app = `sauce-storage:Gutenberg-${ safeBranchName }.app.zip`; // App should be preloaded to sauce storage, this can also be a URL
if ( isLocalEnvironment() ) {
desiredCaps = _.clone( iosLocal );

const iosPlatformVersions = getIOSPlatformVersions();
if ( iosPlatformVersions.length === 0 ) {
throw new Error(
'No iOS simulators available! Please verify that you have iOS simulators installed.'
);
}
// eslint-disable-next-line no-console
console.log(
'Available iOS platform versions:',
iosPlatformVersions.map( ( { name } ) => name )
);

if ( ! desiredCaps.platformVersion ) {
desiredCaps.platformVersion = iosPlatformVersions[ 0 ].version;

// eslint-disable-next-line no-console
console.log(
`Using iOS ${ desiredCaps.platformVersion } platform version`
);
}

desiredCaps.app = path.resolve( localIOSAppPath );
}
}
Expand Down