如何使用黄瓜钩子中的全局变量调用afterScenario

时间:2015-04-22 10:06:02

标签: javascript protractor bdd cucumberjs

我有一个后续场景:

var afterScenario = function(campaignName, that){
    console.log('in after scenario');
    that.After("@cleanup", function(callback){
        console.log('-------IN AFTER SCENARIO--------');
};

我从我的步骤定义文件中调用它:

 var afterScenario = require('../support/afterScenario.js');
 module.exports = function() {
 var newPreCampaignName = null;
this.Given(/^a user is on the Pre-Campaign page$/, function(callback){
        console.log('logged in already');
        newPreCampaignName = 'Automation Campaign 3dHb4';
        console.log(newPreCampaignName);
        setTimeout(callback, 5000);
    });
 var afterHook = new afterScenario(newPreCampaignName,this);
}

即使我在步骤定义中设置全局参数'newPreCampaignName'的值,它也会在此调用中作为null传递:var afterHook = new afterScenario(newPreCampaignName,this);

需要帮助解决这个问题。

0 个答案:

没有答案