Wednesday, October 28, 2020

React Native: Run automation tests by dynamically picking an apk ( or ipa )

It seems not a big deal when you are only develop working on a project and running your builds locally but it does count when working as team and your deployments are automated and running on some tool. In that case the paths to executable files will vary from system to system. In such a case its very important that your working directory is dynamic and after that we are selecting some file to apply may be some transformation or execute to what ever.

Following is an example of this, I wanted to run my react-native UI automation tests for android but pick the apk dynamically and it will work on any member's machine like a charm who is working on this project.

And this single line of code is the king:

var parentDir = path.resolve(process.cwd(), '../..');

The whole wdio local config is as follows:

const path = require('path');
const { config } = require('./wdio.shared.conf');
var parentDir = path.resolve(process.cwd(), '../..');
// ============
// Specs
// ============
config.specs = ['./tests/specs/app*.spec.js'];

config.capabilities = [
    maxInstances: 1,
    platformName: 'Android',
    platformVersion: '8',
    deviceName: 'Pixel_XL_API_27',
    app: `${parentDir}\\android\\app\\build\\outputs
    appWaitActivity: '*',
    noReset: true,
    'goog:chromeOptions': {
      w3c: true,
      args: [ '--no-first-run' ],

exports.config = config;

I hope that small piece of advice with practical code will help you to understand the importance of introducing element of dynamicity in your projects.

The Morning Mash # 8


Blast Off with Blazor: Get to know Blazor and our project by Dave Brock

Introducing C# 9: Native-sized integers by Anthony Giretti

Monitoring Helm releases that use jobs and init containers by Andrew Lock

Help Us Plan EF Core 6.0 by Jeremy

Lets play with cypress - Part 2

 In the first part I explained starting of my automation journey with first command to setup cypres at the end i.e.  npm install cypress -g...