Skip to content

Commit

Permalink
[RNMobile] Add iOS platform version to iOS local e2e capabilities (#2…
Browse files Browse the repository at this point in the history
…9715)

* Add iOS platform version to iOS local e2e caps

* Add iOS platform version automatically in e2e tests

When running the iOS e2e tests locally, we no longer require to specify the platform version because we can fetch the available iOS simulator runtimes and pick the latest one.

* Remove unnecessary condition when setting up the driver

* Add showXcodeLog capability

* Increase WDA launch timeout

* Revert "Add showXcodeLog capability"
  • Loading branch information
fluiddot authored Mar 12, 2021
1 parent eecaf69 commit 547033c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
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

0 comments on commit 547033c

Please sign in to comment.