lundi 25 mars 2019

can I pass parameter from a function in onprepare to overwrite protractor config file

I am trying to call a function(promise) in the onprepare state that would return a specs array of all the tests that needs to be run; I need to pass that to the specs in config file

var Excel_Input = require('./Utility/Excel_Input.js');
var HtmlReporter = require('protractor-beautiful-reporter');
var specArray=[''];
exports.config = {
  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs:specArray,
  allScriptsTimeout: 400000,
  getPageTimeout: 400000,
  jasmineNodeOpts: {
      defaultTimeoutInterval: 400000,
  },

      params: {
      },

  onPrepare: async function() {
      var excelData = new Excel_Input();
     await excelData.readFromExcel('dir','sheetName').then(function (result) { 
             specArray.push(result[0].specPath);
             console.log("spec Array: "+specArray); 
        });
       browser.manage().deleteAllCookies();
        jasmine.getEnv().addReporter(new HtmlReporter({
           baseDirectory: './../XO_Protractor_SOM/Reports/screenshots'
        }).getJasmine2Reporter());
     }
};

the console prints:

spec Array: ,Progression/sampleTest.js

but it is not overwriting the actual specs in config file

Aucun commentaire:

Enregistrer un commentaire