2017-02-27 43 views
0

的問題CucumberJS 2.0.0如何

我一直在使用的輸出前的勾,使我們有特色的名字來命名我的截圖文件,從一開始的方案名稱方案之前鉤以及截圖來自的場景。

,我是在1.3.0得到輸出允許我做一個scenario.getName()要做到這一點,不過,從1.3.0格式已經在2.0.0

有沒有人想出如何做到這一點改變?

守則

// hooks.js 
defineSupportCode(function ({registerHandler, Before}) { 

    Before(function (scenario, callback) { 
     global.scenarioDetails = function(){ 
      return scenario; 
     } 
     callback(); 
    }); 

}); 


//otherFile.js 
let name = scenarioDetails().<somethingHereToGrabTheName>; 

輸出console.log()

ScenarioResult { 
duration: 8043, 
    failureException: null, 
    scenario: 
    Scenario { 
    feature: 
     Feature { 
     description: undefined, 
     keyword: 'Feature', 
     line: 2, 
     name: 'Hello World', 
     tags: [Object], 
     uri: 'Path/to/my.feature', 
     scenarios: [Object] }, 
    keyword: 'Scenario', 
    lines: [ 3 ], 
    name: 'Google Search', 
    tags: [ [Object] ], 
    uri: 'Path/to/my.feature', 
    line: 3, 
    description: undefined, 
    steps: [ [Object], [Object], [Object] ] }, 
    status: 'passed', 
    stepResults: 
    [ StepResult { 
     attachments: [], 
     duration: 1, 
     step: [Object], 
     stepDefinition: [Object], 
     status: 'passed' }, 
    StepResult { 
     attachments: [], 
     duration: 8042, 
     step: [Object], 
     stepDefinition: [Object], 
     status: 'passed' } ] } 

回答

1

答案找到

這是我如何定位的功能,場景和步驟的名字:

  • 對於特徵: feature.name
  • 對於情形: scenario.scenario.name
  • 對於步驟: step.name