/
restarting_browser_between_tests.spec.ts
107 lines (92 loc) · 9.69 KB
/
restarting_browser_between_tests.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
import { expect, ifExitCodeIsOtherThan, logOutput, PickEvent } from '@integration/testing-tools';
import { AsyncOperationAttempted, AsyncOperationCompleted, InteractionStarts, SceneFinished, SceneFinishes, SceneStarts, TestRunFinished } from '@serenity-js/core/lib/events';
import { Description, ExecutionSuccessful, Name } from '@serenity-js/core/lib/model';
import 'mocha';
import { protractor } from '../src/protractor';
describe('@serenity-js/jasmine', function () {
/*
* See:
* - https://github.com/angular/protractor/issues/3234
* - https://github.com/jan-molak/serenity-js/issues/56
*/
this.timeout(30000);
it('supports restarting the browser between test scenarios', () =>
protractor(
'./examples/protractor.conf.js',
'--specs=examples/multiple_passing_scenarios.spec.js',
'--restartBrowserBetweenTests',
)
.then(ifExitCodeIsOtherThan(0, logOutput))
.then(res => {
expect(res.exitCode).to.equal(0);
PickEvent.from(res.events)
.next(SceneStarts, event => expect(event.value.name).to.equal(new Name('A scenario passes the first time')))
.next(InteractionStarts, event => expect(event.value.name).to.equal(new Name(`Jasmine disables synchronisation with Angular`)))
.next(InteractionStarts, event => expect(event.value.name).to.equal(new Name(`Jasmine navigates to 'chrome://version/'`)))
.next(SceneFinishes, event => expect(event.value.name).to.equal(new Name('A scenario passes the first time')))
.next(AsyncOperationAttempted, event => expect(event.taskDescription).to.equal(new Description('[ProtractorReporter] Invoking ProtractorRunner.afterEach...')))
.next(AsyncOperationAttempted, event => expect(event.taskDescription).to.equal(new Description('[Actor] Jasmine discards abilities...')))
.next(AsyncOperationCompleted, event => expect(event.taskDescription).to.equal(new Description('[Actor] Jasmine discarded abilities successfully')))
.next(AsyncOperationCompleted, event => expect(event.taskDescription).to.equal(new Description('[ProtractorReporter] ProtractorRunner.afterEach succeeded')))
.next(SceneFinished, event => expect(event.outcome).to.equal(new ExecutionSuccessful()))
.next(SceneStarts, event => expect(event.value.name).to.equal(new Name('A scenario passes the second time')))
.next(InteractionStarts, event => expect(event.value.name).to.equal(new Name(`Jasmine disables synchronisation with Angular`)))
.next(InteractionStarts, event => expect(event.value.name).to.equal(new Name(`Jasmine navigates to 'chrome://accessibility/'`)))
.next(SceneFinishes, event => expect(event.value.name).to.equal(new Name('A scenario passes the second time')))
.next(AsyncOperationAttempted, event => expect(event.taskDescription).to.equal(new Description('[ProtractorReporter] Invoking ProtractorRunner.afterEach...')))
.next(AsyncOperationAttempted, event => expect(event.taskDescription).to.equal(new Description('[Actor] Jasmine discards abilities...')))
.next(AsyncOperationCompleted, event => expect(event.taskDescription).to.equal(new Description('[Actor] Jasmine discarded abilities successfully')))
.next(AsyncOperationCompleted, event => expect(event.taskDescription).to.equal(new Description('[ProtractorReporter] ProtractorRunner.afterEach succeeded')))
.next(SceneFinished, event => expect(event.outcome).to.equal(new ExecutionSuccessful()))
.next(SceneStarts, event => expect(event.value.name).to.equal(new Name('A scenario passes the third time')))
.next(InteractionStarts, event => expect(event.value.name).to.equal(new Name(`Jasmine disables synchronisation with Angular`)))
.next(InteractionStarts, event => expect(event.value.name).to.equal(new Name(`Jasmine navigates to 'chrome://chrome-urls/'`)))
.next(SceneFinishes, event => expect(event.value.name).to.equal(new Name('A scenario passes the third time')))
.next(AsyncOperationAttempted, event => expect(event.taskDescription).to.equal(new Description('[ProtractorReporter] Invoking ProtractorRunner.afterEach...')))
.next(AsyncOperationAttempted, event => expect(event.taskDescription).to.equal(new Description('[Actor] Jasmine discards abilities...')))
.next(AsyncOperationCompleted, event => expect(event.taskDescription).to.equal(new Description('[Actor] Jasmine discarded abilities successfully')))
.next(AsyncOperationCompleted, event => expect(event.taskDescription).to.equal(new Description('[ProtractorReporter] ProtractorRunner.afterEach succeeded')))
.next(SceneFinished, event => expect(event.outcome).to.equal(new ExecutionSuccessful()))
.next(TestRunFinished, event => expect(event.timestamp).to.not.be.undefined)
;
}));
it('produces the same result when the browser is not restarted between the tests', () =>
protractor(
'./examples/protractor.conf.js',
'--specs=examples/multiple_passing_scenarios.spec.js',
)
.then(ifExitCodeIsOtherThan(0, logOutput))
.then(res => {
expect(res.exitCode).to.equal(0);
PickEvent.from(res.events)
.next(SceneStarts, event => expect(event.value.name).to.equal(new Name('A scenario passes the first time')))
.next(InteractionStarts, event => expect(event.value.name).to.equal(new Name(`Jasmine disables synchronisation with Angular`)))
.next(InteractionStarts, event => expect(event.value.name).to.equal(new Name(`Jasmine navigates to 'chrome://version/'`)))
.next(SceneFinishes, event => expect(event.value.name).to.equal(new Name('A scenario passes the first time')))
.next(AsyncOperationAttempted, event => expect(event.taskDescription).to.equal(new Description('[ProtractorReporter] Invoking ProtractorRunner.afterEach...')))
.next(AsyncOperationAttempted, event => expect(event.taskDescription).to.equal(new Description('[Actor] Jasmine discards abilities...')))
.next(AsyncOperationCompleted, event => expect(event.taskDescription).to.equal(new Description('[Actor] Jasmine discarded abilities successfully')))
.next(AsyncOperationCompleted, event => expect(event.taskDescription).to.equal(new Description('[ProtractorReporter] ProtractorRunner.afterEach succeeded')))
.next(SceneFinished, event => expect(event.outcome).to.equal(new ExecutionSuccessful()))
.next(SceneStarts, event => expect(event.value.name).to.equal(new Name('A scenario passes the second time')))
.next(InteractionStarts, event => expect(event.value.name).to.equal(new Name(`Jasmine disables synchronisation with Angular`)))
.next(InteractionStarts, event => expect(event.value.name).to.equal(new Name(`Jasmine navigates to 'chrome://accessibility/'`)))
.next(SceneFinishes, event => expect(event.value.name).to.equal(new Name('A scenario passes the second time')))
.next(AsyncOperationAttempted, event => expect(event.taskDescription).to.equal(new Description('[ProtractorReporter] Invoking ProtractorRunner.afterEach...')))
.next(AsyncOperationAttempted, event => expect(event.taskDescription).to.equal(new Description('[Actor] Jasmine discards abilities...')))
.next(AsyncOperationCompleted, event => expect(event.taskDescription).to.equal(new Description('[Actor] Jasmine discarded abilities successfully')))
.next(AsyncOperationCompleted, event => expect(event.taskDescription).to.equal(new Description('[ProtractorReporter] ProtractorRunner.afterEach succeeded')))
.next(SceneFinished, event => expect(event.outcome).to.equal(new ExecutionSuccessful()))
.next(SceneStarts, event => expect(event.value.name).to.equal(new Name('A scenario passes the third time')))
.next(InteractionStarts, event => expect(event.value.name).to.equal(new Name(`Jasmine disables synchronisation with Angular`)))
.next(InteractionStarts, event => expect(event.value.name).to.equal(new Name(`Jasmine navigates to 'chrome://chrome-urls/'`)))
.next(SceneFinishes, event => expect(event.value.name).to.equal(new Name('A scenario passes the third time')))
.next(AsyncOperationAttempted, event => expect(event.taskDescription).to.equal(new Description('[ProtractorReporter] Invoking ProtractorRunner.afterEach...')))
.next(AsyncOperationAttempted, event => expect(event.taskDescription).to.equal(new Description('[Actor] Jasmine discards abilities...')))
.next(AsyncOperationCompleted, event => expect(event.taskDescription).to.equal(new Description('[Actor] Jasmine discarded abilities successfully')))
.next(AsyncOperationCompleted, event => expect(event.taskDescription).to.equal(new Description('[ProtractorReporter] ProtractorRunner.afterEach succeeded')))
.next(SceneFinished, event => expect(event.outcome).to.equal(new ExecutionSuccessful()))
.next(TestRunFinished, event => expect(event.timestamp).to.not.be.undefined)
;
}));
});