/
scenario_outlines.spec.ts
96 lines (89 loc) · 4.76 KB
/
scenario_outlines.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
import { expect, ifExitCodeIsOtherThan, logOutput, PickEvent } from '@integration/testing-tools';
import {
SceneFinished,
SceneParametersDetected,
SceneSequenceDetected,
SceneStarts,
} from '@serenity-js/core/lib/events';
import { Category, Description, Name } from '@serenity-js/core/lib/model';
import 'mocha';
import { given } from 'mocha-testdata';
import { CucumberRunner, cucumberVersions } from '../src';
describe('@serenity-js/cucumber', function () {
this.timeout(5000);
given([
...cucumberVersions(1, 2)
.thatRequires(
'node_modules/@serenity-js/cucumber/lib/index.js',
'lib/support/configure_serenity.js',
)
.withStepDefsIn('promise', 'callback', 'synchronous')
.toRun('features/scenario_outlines.feature'),
...cucumberVersions(3, 4, 5, 6)
.thatRequires('lib/support/configure_serenity.js')
.withStepDefsIn('synchronous', 'promise', 'callback')
.withArgs(
'--format', 'node_modules/@serenity-js/cucumber',
)
.toRun('features/scenario_outlines.feature'),
]).
it('recognises scenario outlines as sequences of scenes', (runner: CucumberRunner) => runner.run().
then(ifExitCodeIsOtherThan(1, logOutput)).
then(res => {
expect(res.exitCode).to.equal(1);
const
expectedScenarioName = new Name('Sample outline'),
expectedScenarioCategory = new Category('Serenity/JS recognises scenario outlines'),
outlineLine = 3,
firstScenarioLine = 12,
secondScenarioLine = 13,
expectedExamplesName = new Name('Example results'),
expectedExamplesDescription = new Description('Description of the examples');
PickEvent.from(res.events)
.next(SceneSequenceDetected, event => {
expect(event.value.name).to.equal(expectedScenarioName);
expect(event.value.category).to.equal(expectedScenarioCategory);
expect(event.value.location.line).to.equal(outlineLine);
})
.next(SceneParametersDetected, event => {
expect(event.scenario.name).to.equal(expectedScenarioName);
expect(event.scenario.category).to.equal(expectedScenarioCategory);
expect(event.value.name).to.equal(expectedExamplesName);
expect(event.value.description).to.equal(expectedExamplesDescription);
expect(event.value.values).to.deep.equal({ result: 'passes' });
})
.next(SceneStarts, event => {
expect(event.details.name).to.equal(expectedScenarioName);
expect(event.details.category).to.equal(expectedScenarioCategory);
expect(event.details.location.line).to.equal(firstScenarioLine);
})
.next(SceneFinished, event => {
expect(event.details.name).to.equal(expectedScenarioName);
expect(event.details.category).to.equal(expectedScenarioCategory);
expect(event.details.location.line).to.equal(firstScenarioLine);
})
.next(SceneSequenceDetected, event => {
expect(event.value.name).to.equal(expectedScenarioName);
expect(event.value.category).to.equal(expectedScenarioCategory);
expect(event.value.location.line).to.equal(outlineLine);
})
.next(SceneParametersDetected, event => {
expect(event.scenario.name).to.equal(expectedScenarioName);
expect(event.scenario.category).to.equal(expectedScenarioCategory);
expect(event.value.name).to.equal(expectedExamplesName);
expect(event.value.description).to.equal(expectedExamplesDescription);
expect(event.value.values).to.deep.equal({ result: 'fails with generic error' });
})
.next(SceneStarts, event => {
expect(event.details.name).to.equal(expectedScenarioName);
expect(event.details.category).to.equal(expectedScenarioCategory);
expect(event.details.location.line).to.equal(secondScenarioLine);
})
.next(SceneFinished, event => {
expect(event.details.name).to.equal(expectedScenarioName);
expect(event.details.category).to.equal(expectedScenarioCategory);
expect(event.details.location.line).to.equal(secondScenarioLine);
})
;
}));
});