forked from cucumber/cucumber-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scenario_result.js
41 lines (37 loc) · 1015 Bytes
/
scenario_result.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import Status, {addStatusPredicates} from '../status'
export default class ScenarioResult {
constructor(scenario, status) {
this.duration = 0
this.failureException = null
this.scenario = scenario
this.status = status || Status.PASSED
this.stepResults = []
}
shouldUpdateStatus(stepResultStatus) {
switch (stepResultStatus) {
case Status.FAILED:
return true
case Status.AMBIGUOUS:
case Status.PENDING:
case Status.SKIPPED:
case Status.UNDEFINED:
return this.status === Status.PASSED
default:
return false
}
}
witnessStepResult(stepResult) {
const {duration, failureException, status} = stepResult
if (duration) {
this.duration += duration
}
if (status === Status.FAILED) {
this.failureException = failureException
}
if (this.shouldUpdateStatus(status)) {
this.status = status
}
this.stepResults.push(stepResult)
}
}
addStatusPredicates(ScenarioResult.prototype)