Protractor - Waiting for async task to complete before proceeding with tests
<p>Issue:</p>

<p>I have a helper library that reads data from an excel and returns an array of object. This library is an async function and I am unable to set a global array with the result of this function.
I was planning to read the global array as input source for my protractor tests.</p>

<p>Is there any way how this can be done? Any help would be appreciated.</p>

<p>Helper method:</p>

<pre><code>'use strict';
var exceljs = require('exceljs');
var GetTestData = function(){
    var colName = [];
    var array = [];
    this.getExcelData = function(page){
        var workbook = new exceljs.Workbook();
        return workbook.xlsx.readFile('./TestData/testLogin.xlsx').then(function(){
            var worksheet = workbook.getWorksheet(page);
            var headerRow = worksheet.getRow(1);    
            headerRow.eachCell(function(cell){
                var colObj = {};
                colObj = {header: cell.value, key: cell.value.toLowerCase()};
                colName.push(colObj);
            });
            worksheet.columns = colName;                
            var iter = 0;       
            var rowObj = {};
            worksheet.eachRow(function(row) {           
                if (iter != 0){             
                    if(row.getCell('execute').value == 'Yes'){
                        headerRow.eachCell(function(cell){
                            rowObj[cell.value] = row.getCell(cell.value.toLowerCase()).value;
                        });                         
                    }
                    array.push(rowObj);
                    rowObj = {};
                }           
                iter++;         
            });
            return array;
        });
    };
};

module.exports = function(){
    return new GetTestData();
};
</code></pre>

<p>I want to use the array returned from this function as a data source and loop my tests in it.</p>

<pre><code>'use strict';
var array;
var TestData = require('../../Libraries/ExcelFn.js');
describe('Login Page', function(){
    beforeAll(function(){
        testData.getExcelData('Login').done(function(result){
            array = result;
            console.log(array); //The array returns fine here
        });
    });

    array.forEach(function(data){
        it('should test for each set of test data', function(){
            //Login Tests here
        });
    });     
});
</code></pre>

<p>Result: No specs found</p>

<p>Is there anyway how I can set the result from the helper method (possibly in a parameter in beforeLaunch()) and use that to parameterize my tests?</p>