-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathprogress_formatter_spec.ts
134 lines (111 loc) · 3.31 KB
/
progress_formatter_spec.ts
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import { afterEach, beforeEach, describe, it } from 'mocha'
import { expect } from 'chai'
import { reindent } from 'reindent-template-literals'
import figures from 'figures'
import FakeTimers, { InstalledClock } from '@sinonjs/fake-timers'
import { testFormatter } from '../../test/formatter_helpers'
import { getBaseSupportCodeLibrary } from '../../test/fixtures/steps'
import timeMethods from '../time'
describe('ProgressFormatter', () => {
let clock: InstalledClock
beforeEach(() => {
clock = FakeTimers.withGlobal(timeMethods).install()
})
afterEach(() => {
clock.uninstall()
})
it('outputs a character for each step representing the status and then prints the summary format', async () => {
// Arrange
const sources = [
{
data: reindent(`
Feature: a
Scenario: a1
Given an ambiguous step
Scenario: a2
Given a failing step
Scenario: a3
Given a pending step
Scenario: a4
Given a passing step
Scenario: a5
Given a skipped step
Scenario: a6
Given an undefined step
`),
uri: 'a.feature',
},
]
const supportCodeLibrary = getBaseSupportCodeLibrary()
// Act
const output = await testFormatter({
sources,
supportCodeLibrary,
type: 'progress',
})
// Assert
expect(output).to.eql(
reindent(`
AFP.-U
Failures:
1) Scenario: a1 # a.feature:2
${figures.cross} Given an ambiguous step
Multiple step definitions match:
an ambiguous step - steps.ts:13
/an? ambiguous step/ - steps.ts:14
2) Scenario: a2 # a.feature:4
${figures.cross} Given a failing step # steps.ts:9
error
3) Scenario: a6 # a.feature:12
? Given an undefined step
Undefined. Implement with the following snippet:
Given('an undefined step', function () {
// Write code here that turns the phrase above into concrete actions
return 'pending';
});
Warnings:
1) Scenario: a3 # a.feature:6
? Given a pending step # steps.ts:16
Pending
6 scenarios (1 failed, 1 ambiguous, 1 undefined, 1 pending, 1 skipped, 1 passed)
6 steps (1 failed, 1 ambiguous, 1 undefined, 1 pending, 1 skipped, 1 passed)
<duration-stat>
`)
)
})
it('handles rule/example results', async () => {
// Arrange
const sources = [
{
data: reindent(`
Feature: feature
Rule: rule1
Example: example1
Given a passing step
Example: example2
Given a passing step
Rule: rule2
Example: example1
Given a passing step
`),
uri: 'a.feature',
},
]
const supportCodeLibrary = getBaseSupportCodeLibrary()
// Act
const output = await testFormatter({
sources,
supportCodeLibrary,
type: 'progress',
})
// Assert
expect(output).to.eql(
reindent(`
...
3 scenarios (3 passed)
3 steps (3 passed)
<duration-stat>
`)
)
})
})