@serenity-js/core 2.32.5 → 3.0.0-rc.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (190) hide show
  1. package/CHANGELOG.md +79 -0
  2. package/lib/index.d.ts +2 -1
  3. package/lib/index.js +4 -1
  4. package/lib/index.js.map +1 -1
  5. package/lib/io/ErrorSerialiser.js +4 -1
  6. package/lib/io/ErrorSerialiser.js.map +1 -1
  7. package/lib/io/asyncMap.d.ts +8 -0
  8. package/lib/io/asyncMap.js +18 -0
  9. package/lib/io/asyncMap.js.map +1 -0
  10. package/lib/io/format.d.ts +37 -0
  11. package/lib/io/format.js +49 -0
  12. package/lib/io/format.js.map +1 -0
  13. package/lib/io/formatted.d.ts +5 -1
  14. package/lib/io/formatted.js +6 -13
  15. package/lib/io/formatted.js.map +1 -1
  16. package/lib/io/index.d.ts +2 -1
  17. package/lib/io/index.js +2 -1
  18. package/lib/io/index.js.map +1 -1
  19. package/lib/io/inspected.d.ts +9 -1
  20. package/lib/io/inspected.js +50 -14
  21. package/lib/io/inspected.js.map +1 -1
  22. package/lib/model/Timestamp.d.ts +4 -2
  23. package/lib/model/Timestamp.js +8 -2
  24. package/lib/model/Timestamp.js.map +1 -1
  25. package/lib/screenplay/Question.d.ts +6 -83
  26. package/lib/screenplay/Question.js +14 -98
  27. package/lib/screenplay/Question.js.map +1 -1
  28. package/lib/screenplay/actor/Actor.js +2 -2
  29. package/lib/screenplay/actor/Actor.js.map +1 -1
  30. package/lib/screenplay/index.d.ts +1 -1
  31. package/lib/screenplay/index.js +1 -1
  32. package/lib/screenplay/index.js.map +1 -1
  33. package/lib/screenplay/model/Adapter.d.ts +8 -0
  34. package/lib/{io/collections/reducible.js → screenplay/model/Adapter.js} +1 -1
  35. package/lib/screenplay/model/Adapter.js.map +1 -0
  36. package/lib/screenplay/model/createAdapter.d.ts +3 -0
  37. package/lib/screenplay/model/createAdapter.js +118 -0
  38. package/lib/screenplay/model/createAdapter.js.map +1 -0
  39. package/lib/screenplay/model/index.d.ts +2 -0
  40. package/lib/screenplay/{tasks → model}/index.js +2 -1
  41. package/lib/screenplay/model/index.js.map +1 -0
  42. package/lib/screenplay/questions/Expectation.d.ts +11 -0
  43. package/lib/screenplay/questions/Expectation.js +18 -1
  44. package/lib/screenplay/questions/Expectation.js.map +1 -1
  45. package/lib/screenplay/questions/List.d.ts +22 -191
  46. package/lib/screenplay/questions/List.js +162 -208
  47. package/lib/screenplay/questions/List.js.map +1 -1
  48. package/lib/screenplay/questions/Note.d.ts +10 -0
  49. package/lib/screenplay/questions/Note.js +17 -1
  50. package/lib/screenplay/questions/Note.js.map +1 -1
  51. package/lib/screenplay/questions/index.d.ts +0 -3
  52. package/lib/screenplay/questions/index.js +0 -5
  53. package/lib/screenplay/questions/index.js.map +1 -1
  54. package/package.json +6 -6
  55. package/src/index.ts +2 -1
  56. package/src/io/ErrorSerialiser.ts +5 -1
  57. package/src/io/asyncMap.ts +18 -0
  58. package/src/io/format.ts +46 -0
  59. package/src/io/formatted.ts +7 -15
  60. package/src/io/index.ts +2 -1
  61. package/src/io/inspected.ts +66 -14
  62. package/src/model/Timestamp.ts +10 -2
  63. package/src/screenplay/Question.ts +21 -119
  64. package/src/screenplay/actor/Actor.ts +2 -2
  65. package/src/screenplay/index.ts +1 -1
  66. package/src/screenplay/model/Adapter.ts +14 -0
  67. package/src/screenplay/model/createAdapter.ts +149 -0
  68. package/src/screenplay/model/index.ts +2 -0
  69. package/src/screenplay/questions/Expectation.ts +20 -1
  70. package/src/screenplay/questions/List.ts +228 -232
  71. package/src/screenplay/questions/Note.ts +21 -1
  72. package/src/screenplay/questions/index.ts +0 -3
  73. package/lib/io/collections/index.d.ts +0 -2
  74. package/lib/io/collections/index.js +0 -15
  75. package/lib/io/collections/index.js.map +0 -1
  76. package/lib/io/collections/mappable.d.ts +0 -52
  77. package/lib/io/collections/mappable.js +0 -28
  78. package/lib/io/collections/mappable.js.map +0 -1
  79. package/lib/io/collections/reducible.d.ts +0 -16
  80. package/lib/io/collections/reducible.js.map +0 -1
  81. package/lib/screenplay/questions/Property.d.ts +0 -91
  82. package/lib/screenplay/questions/Property.js +0 -99
  83. package/lib/screenplay/questions/Property.js.map +0 -1
  84. package/lib/screenplay/questions/Transform.d.ts +0 -31
  85. package/lib/screenplay/questions/Transform.js +0 -46
  86. package/lib/screenplay/questions/Transform.js.map +0 -1
  87. package/lib/screenplay/questions/lists/ArrayListAdapter.d.ts +0 -88
  88. package/lib/screenplay/questions/lists/ArrayListAdapter.js +0 -152
  89. package/lib/screenplay/questions/lists/ArrayListAdapter.js.map +0 -1
  90. package/lib/screenplay/questions/lists/ListAdapter.d.ts +0 -20
  91. package/lib/screenplay/questions/lists/ListAdapter.js +0 -3
  92. package/lib/screenplay/questions/lists/ListAdapter.js.map +0 -1
  93. package/lib/screenplay/questions/lists/index.d.ts +0 -2
  94. package/lib/screenplay/questions/lists/index.js +0 -15
  95. package/lib/screenplay/questions/lists/index.js.map +0 -1
  96. package/lib/screenplay/questions/mappings/AnswerMappingFunction.d.ts +0 -11
  97. package/lib/screenplay/questions/mappings/AnswerMappingFunction.js +0 -3
  98. package/lib/screenplay/questions/mappings/AnswerMappingFunction.js.map +0 -1
  99. package/lib/screenplay/questions/mappings/index.d.ts +0 -2
  100. package/lib/screenplay/questions/mappings/index.js +0 -15
  101. package/lib/screenplay/questions/mappings/index.js.map +0 -1
  102. package/lib/screenplay/questions/mappings/string/append.d.ts +0 -14
  103. package/lib/screenplay/questions/mappings/string/append.js +0 -25
  104. package/lib/screenplay/questions/mappings/string/append.js.map +0 -1
  105. package/lib/screenplay/questions/mappings/string/index.d.ts +0 -11
  106. package/lib/screenplay/questions/mappings/string/index.js +0 -24
  107. package/lib/screenplay/questions/mappings/string/index.js.map +0 -1
  108. package/lib/screenplay/questions/mappings/string/normalize.d.ts +0 -20
  109. package/lib/screenplay/questions/mappings/string/normalize.js +0 -30
  110. package/lib/screenplay/questions/mappings/string/normalize.js.map +0 -1
  111. package/lib/screenplay/questions/mappings/string/replace.d.ts +0 -17
  112. package/lib/screenplay/questions/mappings/string/replace.js +0 -30
  113. package/lib/screenplay/questions/mappings/string/replace.js.map +0 -1
  114. package/lib/screenplay/questions/mappings/string/slice.d.ts +0 -28
  115. package/lib/screenplay/questions/mappings/string/slice.js +0 -47
  116. package/lib/screenplay/questions/mappings/string/slice.js.map +0 -1
  117. package/lib/screenplay/questions/mappings/string/split.d.ts +0 -19
  118. package/lib/screenplay/questions/mappings/string/split.js +0 -36
  119. package/lib/screenplay/questions/mappings/string/split.js.map +0 -1
  120. package/lib/screenplay/questions/mappings/string/toLocaleLowerCase.d.ts +0 -17
  121. package/lib/screenplay/questions/mappings/string/toLocaleLowerCase.js +0 -28
  122. package/lib/screenplay/questions/mappings/string/toLocaleLowerCase.js.map +0 -1
  123. package/lib/screenplay/questions/mappings/string/toLocaleUpperCase.d.ts +0 -17
  124. package/lib/screenplay/questions/mappings/string/toLocaleUpperCase.js +0 -29
  125. package/lib/screenplay/questions/mappings/string/toLocaleUpperCase.js.map +0 -1
  126. package/lib/screenplay/questions/mappings/string/toLowerCase.d.ts +0 -10
  127. package/lib/screenplay/questions/mappings/string/toLowerCase.js +0 -19
  128. package/lib/screenplay/questions/mappings/string/toLowerCase.js.map +0 -1
  129. package/lib/screenplay/questions/mappings/string/toNumber.d.ts +0 -10
  130. package/lib/screenplay/questions/mappings/string/toNumber.js +0 -18
  131. package/lib/screenplay/questions/mappings/string/toNumber.js.map +0 -1
  132. package/lib/screenplay/questions/mappings/string/toUpperCase.d.ts +0 -10
  133. package/lib/screenplay/questions/mappings/string/toUpperCase.js +0 -19
  134. package/lib/screenplay/questions/mappings/string/toUpperCase.js.map +0 -1
  135. package/lib/screenplay/questions/mappings/string/trim.d.ts +0 -12
  136. package/lib/screenplay/questions/mappings/string/trim.js +0 -21
  137. package/lib/screenplay/questions/mappings/string/trim.js.map +0 -1
  138. package/lib/screenplay/questions/proxies/PropertyPathKey.d.ts +0 -4
  139. package/lib/screenplay/questions/proxies/PropertyPathKey.js +0 -3
  140. package/lib/screenplay/questions/proxies/PropertyPathKey.js.map +0 -1
  141. package/lib/screenplay/questions/proxies/createMetaQuestionProxy.d.ts +0 -14
  142. package/lib/screenplay/questions/proxies/createMetaQuestionProxy.js +0 -35
  143. package/lib/screenplay/questions/proxies/createMetaQuestionProxy.js.map +0 -1
  144. package/lib/screenplay/questions/proxies/createQuestionProxy.d.ts +0 -13
  145. package/lib/screenplay/questions/proxies/createQuestionProxy.js +0 -34
  146. package/lib/screenplay/questions/proxies/createQuestionProxy.js.map +0 -1
  147. package/lib/screenplay/questions/proxies/describePath.d.ts +0 -5
  148. package/lib/screenplay/questions/proxies/describePath.js +0 -19
  149. package/lib/screenplay/questions/proxies/describePath.js.map +0 -1
  150. package/lib/screenplay/questions/proxies/index.d.ts +0 -2
  151. package/lib/screenplay/questions/proxies/index.js +0 -15
  152. package/lib/screenplay/questions/proxies/index.js.map +0 -1
  153. package/lib/screenplay/questions/proxies/key.d.ts +0 -8
  154. package/lib/screenplay/questions/proxies/key.js +0 -16
  155. package/lib/screenplay/questions/proxies/key.js.map +0 -1
  156. package/lib/screenplay/tasks/Loop.d.ts +0 -198
  157. package/lib/screenplay/tasks/Loop.js +0 -222
  158. package/lib/screenplay/tasks/Loop.js.map +0 -1
  159. package/lib/screenplay/tasks/index.d.ts +0 -1
  160. package/lib/screenplay/tasks/index.js.map +0 -1
  161. package/src/io/collections/index.ts +0 -2
  162. package/src/io/collections/mappable.ts +0 -60
  163. package/src/io/collections/reducible.ts +0 -16
  164. package/src/screenplay/questions/Property.ts +0 -98
  165. package/src/screenplay/questions/Transform.ts +0 -51
  166. package/src/screenplay/questions/lists/ArrayListAdapter.ts +0 -186
  167. package/src/screenplay/questions/lists/ListAdapter.ts +0 -33
  168. package/src/screenplay/questions/lists/index.ts +0 -2
  169. package/src/screenplay/questions/mappings/AnswerMappingFunction.ts +0 -13
  170. package/src/screenplay/questions/mappings/index.ts +0 -2
  171. package/src/screenplay/questions/mappings/string/append.ts +0 -28
  172. package/src/screenplay/questions/mappings/string/index.ts +0 -11
  173. package/src/screenplay/questions/mappings/string/normalize.ts +0 -33
  174. package/src/screenplay/questions/mappings/string/replace.ts +0 -34
  175. package/src/screenplay/questions/mappings/string/slice.ts +0 -53
  176. package/src/screenplay/questions/mappings/string/split.ts +0 -38
  177. package/src/screenplay/questions/mappings/string/toLocaleLowerCase.ts +0 -31
  178. package/src/screenplay/questions/mappings/string/toLocaleUpperCase.ts +0 -30
  179. package/src/screenplay/questions/mappings/string/toLowerCase.ts +0 -20
  180. package/src/screenplay/questions/mappings/string/toNumber.ts +0 -19
  181. package/src/screenplay/questions/mappings/string/toUpperCase.ts +0 -20
  182. package/src/screenplay/questions/mappings/string/trim.ts +0 -22
  183. package/src/screenplay/questions/proxies/PropertyPathKey.ts +0 -4
  184. package/src/screenplay/questions/proxies/createMetaQuestionProxy.ts +0 -51
  185. package/src/screenplay/questions/proxies/createQuestionProxy.ts +0 -49
  186. package/src/screenplay/questions/proxies/describePath.ts +0 -23
  187. package/src/screenplay/questions/proxies/index.ts +0 -2
  188. package/src/screenplay/questions/proxies/key.ts +0 -14
  189. package/src/screenplay/tasks/Loop.ts +0 -240
  190. package/src/screenplay/tasks/index.ts +0 -1
@@ -1,49 +0,0 @@
1
- /* eslint-disable @typescript-eslint/ban-types */
2
- import { formatted } from '../../../io';
3
- import { Answerable } from '../../Answerable';
4
- import { Question } from '../../Question';
5
- import { describePath } from './describePath';
6
- import { key } from './key';
7
- import { PropertyPathKey } from './PropertyPathKey';
8
-
9
- /**
10
- * @package
11
- */
12
- export type WithPropertiesAsQuestions<Original_Type> = {
13
- [Key in keyof Original_Type]: Original_Type[Key] extends object
14
- ? Question<Promise<Original_Type[Key]>> & WithPropertiesAsQuestions<Original_Type[Key]>
15
- : Question<Promise<Original_Type[Key]>>
16
- }
17
-
18
- /**
19
- * @package
20
- */
21
- export function createQuestionProxy<Original_Type extends object>(subject: Answerable<Original_Type>, path: PropertyPathKey[] = []): WithPropertiesAsQuestions<Original_Type> {
22
-
23
- const empty = {};
24
-
25
- return new Proxy<Original_Type>(empty as any, {
26
- get(target: unknown, name: PropertyPathKey) {
27
-
28
- if (key(name).isOneOf<Question<any>>('answeredBy', 'describedAs', 'map', 'toString')) {
29
-
30
- const question = Question.about(formatted `property ${ describePath(path) } of ${ subject }`, actor => {
31
- return actor.answer(subject).then(answer => {
32
-
33
- return path.reduce((subObject, keyName, index) => {
34
- if (keyName in subObject) {
35
- return subObject[keyName];
36
- }
37
- throw new Error(formatted `property ${ describePath(path.slice(0, index + 1)) } of ${ subject } doesn't exist`);
38
- }, answer);
39
-
40
- })
41
- });
42
-
43
- return question[name].bind(question); // eslint-disable-line unicorn/prefer-prototype-methods
44
- }
45
-
46
- return createQuestionProxy(subject, path.concat(name));
47
- }
48
- }) as WithPropertiesAsQuestions<Original_Type>;
49
- }
@@ -1,23 +0,0 @@
1
- import { PropertyPathKey } from './PropertyPathKey';
2
-
3
- /**
4
- * @package
5
- */
6
- export function describePath(parts: PropertyPathKey[]): string {
7
- return parts.reduce(
8
- (acc, segment) =>
9
- acc.concat(
10
- isNumber(segment)
11
- ? `[${ segment }]`
12
- : segment
13
- ),
14
- [],
15
- ).join('.');
16
- }
17
-
18
- /**
19
- * @private
20
- */
21
- function isNumber(segment: PropertyPathKey): segment is number {
22
- return Number.parseInt(String(segment), 10).toString() === segment;
23
- }
@@ -1,2 +0,0 @@
1
- export * from './createMetaQuestionProxy';
2
- export * from './createQuestionProxy';
@@ -1,14 +0,0 @@
1
- /* eslint-disable @typescript-eslint/ban-types,@typescript-eslint/explicit-module-boundary-types */
2
- import { PropertyPathKey } from './PropertyPathKey';
3
-
4
- /**
5
- * @package
6
- * @param {PropertyPathKey} keyName
7
- */
8
- export function key(keyName: PropertyPathKey) {
9
- return {
10
- isOneOf<T extends object = object>(...keys: Array<keyof T>) {
11
- return !!~keys.indexOf(keyName as any);
12
- }
13
- }
14
- }
@@ -1,240 +0,0 @@
1
- import { formatted, Reducible } from '../../io';
2
- import { Activity } from '../Activity';
3
- import { AnswersQuestions, PerformsActivities, UsesAbilities } from '../actor';
4
- import { Answerable } from '../Answerable';
5
- import { Question } from '../Question';
6
- import { Task } from '../Task';
7
-
8
- /**
9
- * @desc
10
- * Enables the {@link Actor} to iterate over a list of items produced by any {@link Answerable}.
11
- *
12
- * You can think of `Loop` as a more sophisticated Screenplay-style equivalent of
13
- * [`Array.forEach`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach).
14
- * `Loop` is capable of working with both synchronous data structures,
15
- * such as [`Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)
16
- * and `Question<Array<T>>`,
17
- * as well as asynchronous ones, so `Promise<Array<T>>` and `Question<Promise<Array<T>>>`.
18
- *
19
- * Use {@link Loop.item} to access the current item being processed by {@link Loop}, and {@link Loop.index}
20
- * to access the index of {@link Loop.item} in the list.
21
- *
22
- * @example <caption>Basic scenario - Iterating over a static list of items</caption>
23
- * import { actorCalled, Loop, Log } from '@serenity-js/core';
24
- *
25
- * actorCalled('Joe').attemptsTo(
26
- * Loop.over([ 'apple', 'banana', 'candy' ]).to(
27
- * Log.the('current element', Loop.item<string>()),
28
- * Log.the('current index', Loop.index()),
29
- * ),
30
- * );
31
- *
32
- * @example <caption>API scenario - Iterating over items in an API response</caption>
33
- *
34
- * import { actorCalled, Loop } from '@serenity-js/core';
35
- * import { Send, GetRequest, CallAnApi, LastResponse } from '@serenity-js/rest';
36
- * import { Ensure, property, isGreaterThan } from '@serenity-js/assertions';
37
- *
38
- * interface TodoItem {
39
- * userId: number;
40
- * id: number;
41
- * title: string;
42
- * completed: boolean;
43
- * }
44
- *
45
- * actorCalled('Joe').whoCan(
46
- * CallAnApi.at('https://jsonplaceholder.typicode.com')
47
- * ).attemptsTo(
48
- * Send.a(GetRequest.to('/todos')),
49
- * Loop.over(LastResponse.body<TodoItem[]>()).to(
50
- * Ensure.that(
51
- * Loop.item<TodoItem>(),
52
- * property('userId', isGreaterThan(0)),
53
- * ),
54
- * )
55
- * );
56
- *
57
- * @example <caption>UI scenario - Example widget</caption>
58
- * <nav>
59
- * <div data-test="cookies">
60
- * <label for="functional-cookies">
61
- * <input type="checkbox" id="functional-cookies" />Allow functional cookies
62
- * </label>
63
- * <label for="performance-cookies">
64
- * <input type="checkbox" id="performance-cookies" />Allow performance cookies
65
- * </label>
66
- * <label for="advertising-cookies">
67
- * <input type="checkbox" id="advertising-cookies" />Allow advertising cookies
68
- * </label>
69
- * </div>
70
- * </nav>
71
- *
72
- * @example <caption>UI scenario - Lean Page Object</caption>
73
- * import { Target } from '@serenity-js/protractor';
74
- * import { browser, by } from 'protractor';
75
- *
76
- * class Cookies {
77
- * static labels = Target.all('cookie options')
78
- * .located(by.css('[data-test="cookies"]'));
79
- *
80
- * static checkbox = Target.the('checkbox')
81
- * .located(by.tagName('input')),
82
- * }
83
- *
84
- * @example <caption>UI scenario - Performing the same set of activities with each element</caption>
85
- * import { actorCalled, Loop } from '@serenity-js/core';
86
- * import { Click, Text, isSelected } from '@serenity-js/protractor';
87
- * import { Ensure, startsWith } from '@serenity-js/assertions';
88
- * import { protractor } from 'protractor';
89
- *
90
- * actorCalled('Joe')
91
- * .whoCan(BrowseTheWeb.using(protractor.browser))
92
- * .attemptsTo(
93
- * Loop.over(Cookies.labels).to(
94
- * Ensure.that(
95
- * Text.of(Loop.item<ElementFinder>()),
96
- * startsWith('Allow'),
97
- * ),
98
- *
99
- * Click.on(Loop.item<ElementFinder>()),
100
- * Ensure.that(
101
- * Cookies.checkbox.of(Loop.item<ElementFinder>()),
102
- * isSelected(),
103
- * ),
104
- * ),
105
- * );
106
- *
107
- * @extends {Task}
108
- *
109
- * @see {@link Loop.item}
110
- * @see {@link Loop.index}
111
- * @see {@link Question}
112
- */
113
- export class Loop<Item> extends Task {
114
- private static currentItem: unknown = undefined;
115
- private static currentIndex = 0;
116
-
117
- /**
118
- * @desc
119
- * Instantiates a {@link Task} to {@link Loop}
120
- * that enables the {@link Actor} to iterate over `items`
121
- * to perform some `activities`.
122
- *
123
- * @param {items: Answerable<ReducibleCollection>} items
124
- * @returns {LoopBuilder}
125
- */
126
- static over<T>(items: Answerable<Reducible>): { to: (...activities: Activity[]) => Loop<T> } {
127
- return {
128
- to: (...activities: Activity[]) =>
129
- new Loop<T>(items, activities)
130
- }
131
- }
132
-
133
- /**
134
- * @desc
135
- * Returns the current item being processed by {@link Loop.over}.
136
- *
137
- * **Please note** that in order for the TypeScript transpiler to understand the exact `ExpectedType`
138
- * of the {@link Question} produced by this method you can optionally configure it with
139
- * a [_type variable_](https://www.typescriptlang.org/docs/handbook/generics.html).
140
- *
141
- * For example, configuring the method with type variable of `string`, so `Loop.item<string>()`,
142
- * tells the transpiler that a `Question<string>` will be returned.
143
- *
144
- * If the type variable is not configured, the transpiler assumes that returned type is a
145
- * `Question<any>`. This means that while your code could still work, you'd miss out
146
- * on checking provided by TypeScript.
147
- *
148
- * @returns {Question<ExpectedType>}
149
- */
150
- static item<ExpectedType = any>(): Question<ExpectedType> {
151
- return Question.about<ExpectedType>(`current loop item`, actor =>
152
- Loop.currentItem as ExpectedType,
153
- );
154
- }
155
-
156
- /**
157
- * @desc
158
- * Returns the index of current {@link Loop.item} in the `Answerable<Array>` given to {@link Loop.over}.
159
- *
160
- * The index starts at `0`.
161
- *
162
- * @returns {Question<number>}
163
- */
164
- static index(): Question<number> {
165
- return Question.about<number>(`current loop index`, actor =>
166
- Loop.currentIndex,
167
- );
168
- }
169
-
170
- /**
171
- * @param {Answerable<Reducible>} items
172
- * @param {Activity[]} activities
173
- */
174
- constructor(
175
- private readonly items: Answerable<Reducible>,
176
- private readonly activities: Activity[]
177
- ) {
178
- super();
179
- }
180
-
181
- /**
182
- * @desc
183
- * Makes the provided {@link Actor}
184
- * perform this {@link Task}.
185
- *
186
- * @param {PerformsActivities & UsesAbilities & AnswersQuestions} actor
187
- * @returns {Promise<void>}
188
- *
189
- * @see {@link Actor}
190
- * @see {@link PerformsActivities}
191
- * @see {@link UsesAbilities}
192
- * @see {@link AnswersQuestions}
193
- */
194
- performAs(actor: PerformsActivities & UsesAbilities & AnswersQuestions): PromiseLike<void> | PromiseLike<any> {
195
- return actor.answer(this.items)
196
- .then(items =>
197
- items.reduce((previous: Promise<void>, current: Item, index: number) => {
198
- return previous.then(() => {
199
- Loop.currentIndex = index;
200
- Loop.currentItem = current;
201
-
202
- return actor.attemptsTo(
203
- ...this.activities
204
- );
205
- });
206
- }, Promise.resolve(void 0))
207
- );
208
- }
209
-
210
- /**
211
- * @desc
212
- * Generates a description to be used when reporting this {@link Activity}.
213
- *
214
- * @returns {string}
215
- */
216
- toString(): string {
217
- const description = Array.isArray(this.items)
218
- ? `a list of ${ this.items.length } item${ this.items.length !== 1 ? 's' : '' }`
219
- : formatted `${ this.items }`;
220
-
221
- return `#actor loops over ${ description }`;
222
- }
223
- }
224
-
225
- /**
226
- * @typedef {Object} LoopBuilder
227
- * @property {function(...activities: Activity[]): Loop} to
228
- *
229
- * @example <caption>Basic scenario - Iterating over a static list of items</caption>
230
- * import { actorCalled, Loop, Log } from '@serenity-js/core';
231
- *
232
- * actorCalled('Joe').attemptsTo(
233
- * Loop.over([ 'apple', 'banana', 'candy' ]).to(
234
- * Log.the('current element', Loop.item<string>()),
235
- * ),
236
- * );
237
- *
238
- * @see {@link Loop}
239
- * @see {@link Loop.over}
240
- */
@@ -1 +0,0 @@
1
- export * from './Loop';