protractor-cucumber-framework
Advanced tools
Comparing version 2.3.0 to 3.0.0
@@ -14,3 +14,2 @@ let q = require('q'); | ||
function registerHandlers() { | ||
let scenarioDuration = 0; | ||
let scenarioFailed = false; | ||
@@ -24,23 +23,5 @@ let stepResults = buildStepResults(); | ||
this.registerHandler('BeforeScenario', function (scenario, callback) { | ||
scenarioDuration = 0; | ||
callback(); | ||
}); | ||
this.registerHandler('AfterScenario', function (scenario, callback) { | ||
let feature = getter(scenario, 'feature'); | ||
let scenarioInfo = { | ||
name: getter(scenario, 'name'), | ||
category: getter(feature, 'name'), | ||
durationMillis: isCucumber2() ? scenarioDuration : (Math.round(scenarioDuration / 1e6)) | ||
}; | ||
stepResults.description = scenarioInfo.name; | ||
if (scenarioFailed) { | ||
++state.results.failedCount; | ||
state.runner.emit('testFail', scenarioInfo); | ||
} else { | ||
state.runner.emit('testPass', scenarioInfo); | ||
} | ||
if (scenarioFailed) ++state.results.failedCount; | ||
stepResults.description = getter(scenario, 'name'); | ||
state.results.specResults.push(stepResults); | ||
@@ -55,6 +36,8 @@ stepResults = buildStepResults(); | ||
this.registerHandler('StepResult', function(stepResult, callback) { | ||
let failureMessage; | ||
let step = getter(stepResult, 'step'); | ||
let scenario = getter(step, 'scenario'); | ||
let feature = getter(scenario, 'feature'); | ||
if (!scenario.uri) scenario.uri = feature.uri; | ||
let emitterEvent = 'testPass'; | ||
scenarioDuration += getter(stepResult, 'duration'); | ||
switch (getter(stepResult, 'status')) { | ||
@@ -65,8 +48,8 @@ case Cucumber.Status.PASSED: | ||
case Cucumber.Status.FAILED: | ||
emitterEvent = 'testFail'; | ||
scenarioFailed = true; | ||
failureMessage = getter(stepResult, 'failureException'); | ||
stepResults.assertions.push({ | ||
passed: false, | ||
errorMsg: failureMessage.message, | ||
stackTrace: failureMessage.stack | ||
errorMsg: getter(stepResult, 'failureException').message, | ||
stackTrace: getter(stepResult, 'failureException').stack | ||
}); | ||
@@ -76,2 +59,3 @@ break; | ||
if (state.strict) { | ||
emitterEvent = 'testFail'; | ||
scenarioFailed = true; | ||
@@ -86,3 +70,11 @@ stepResults.assertions.push({ | ||
stepResults.duration += getter(stepResult, 'duration'); | ||
let duration = getter(stepResult, 'duration'); | ||
if (isCucumber1()) duration = Math.round(duration / 1e6); | ||
state.runner.emit(emitterEvent, { | ||
name: `${getter(step, 'keyword')}${getter(step, 'name') || ''}`, | ||
category: `${getter(feature, 'name')}: ${getter(scenario, 'name')}`, | ||
durationMillis: duration | ||
}); | ||
callback(); | ||
@@ -110,4 +102,5 @@ }); | ||
function isCucumber2() { | ||
return !!Cucumber.defineSupportCode; | ||
function isCucumber1() { | ||
return !Cucumber.defineSupportCode; | ||
} | ||
{ | ||
"name": "protractor-cucumber-framework", | ||
"version": "2.3.0", | ||
"version": "3.0.0", | ||
"description": "Protractor framework for Cucumber.js", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
20829
428