@serenity-js/rest 3.0.0-rc.1 → 3.0.0-rc.12

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.
package/CHANGELOG.md CHANGED
@@ -3,14 +3,310 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [3.0.0-rc.12](https://github.com/serenity-js/serenity-js/compare/v2.33.2...v3.0.0-rc.12) (2022-02-23)
7
+
8
+
9
+
10
+ # [3.0.0-rc.11](https://github.com/serenity-js/serenity-js/compare/v2.33.1...v3.0.0-rc.11) (2022-02-13)
11
+
12
+
13
+
14
+ # [3.0.0-rc.10](https://github.com/serenity-js/serenity-js/compare/v2.33.0...v3.0.0-rc.10) (2022-02-03)
15
+
16
+
17
+
18
+ # [3.0.0-rc.9](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.8...v3.0.0-rc.9) (2022-02-01)
19
+
20
+
21
+
22
+ # [3.0.0-rc.8](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.7...v3.0.0-rc.8) (2022-01-28)
23
+
24
+
25
+
26
+ # [3.0.0-rc.7](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.6...v3.0.0-rc.7) (2022-01-28)
27
+
28
+
29
+ ### Features
30
+
31
+ * **core:** replaced `Adapter` with `QuestionAdapter` and introduced `Optional` ([8d84ad3](https://github.com/serenity-js/serenity-js/commit/8d84ad3863e3c726533d0f21934fb1e2fa8b3022)), closes [#1103](https://github.com/serenity-js/serenity-js/issues/1103)
32
+
33
+
34
+
35
+ # [3.0.0-rc.6](https://github.com/serenity-js/serenity-js/compare/v2.32.7...v3.0.0-rc.6) (2022-01-10)
36
+
37
+
38
+
39
+ # [3.0.0-rc.5](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.4...v3.0.0-rc.5) (2022-01-07)
40
+
41
+
42
+
43
+ # [3.0.0-rc.4](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.3...v3.0.0-rc.4) (2021-12-30)
44
+
45
+
46
+ ### Bug Fixes
47
+
48
+ * **core:** you can now retrieve the .length property of an Array wrapped in an Adapter<Array> ([c36e210](https://github.com/serenity-js/serenity-js/commit/c36e210c024052b96ba47e9663c7098e269c5688))
49
+
50
+
51
+
52
+ # [3.0.0-rc.3](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.2...v3.0.0-rc.3) (2021-12-29)
53
+
54
+
55
+ ### Bug Fixes
56
+
57
+ * **rest:** corrected LastResponse to wrap .status(), .body(), .header() and .headers() in Adapters ([aab8e93](https://github.com/serenity-js/serenity-js/commit/aab8e93a19005710d9f333756cdae5aa21c31058)), closes [#1082](https://github.com/serenity-js/serenity-js/issues/1082)
58
+
59
+
60
+
61
+ # [3.0.0-rc.2](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.1...v3.0.0-rc.2) (2021-12-09)
62
+
63
+
64
+
65
+ # [3.0.0-rc.1](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.0...v3.0.0-rc.1) (2021-12-09)
66
+
67
+
68
+
69
+ # [3.0.0-rc.0](https://github.com/serenity-js/serenity-js/compare/v2.32.5...v3.0.0-rc.0) (2021-12-08)
70
+
71
+
72
+ ### Bug Fixes
73
+
74
+ * **core:** 3.0 RC ([469d54e](https://github.com/serenity-js/serenity-js/commit/469d54e4f81ef430566b93852e3174826f8ef672)), closes [#805](https://github.com/serenity-js/serenity-js/issues/805)
75
+
76
+
77
+ ### Features
78
+
79
+ * **core:** question.about produces "props" that proxy the methods of the underlying model ([f771872](https://github.com/serenity-js/serenity-js/commit/f771872c56b487e404002c3800fc8f3baaed804f))
80
+
81
+
82
+ ### BREAKING CHANGES
83
+
84
+ * **core:** Introduced @serenity-js/web - a shared library for Serenity/JS Web integration
85
+ modules such as @serenity-js/protractor and @serenity-js/webdriverio. Dropped support for Node 12.
86
+
87
+
88
+
89
+
90
+
91
+ # [3.0.0-rc.11](https://github.com/serenity-js/serenity-js/compare/v2.33.1...v3.0.0-rc.11) (2022-02-13)
92
+
93
+
94
+
95
+ # [3.0.0-rc.10](https://github.com/serenity-js/serenity-js/compare/v2.33.0...v3.0.0-rc.10) (2022-02-03)
96
+
97
+
98
+
99
+ # [3.0.0-rc.9](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.8...v3.0.0-rc.9) (2022-02-01)
100
+
101
+
102
+
103
+ # [3.0.0-rc.8](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.7...v3.0.0-rc.8) (2022-01-28)
104
+
105
+
106
+
107
+ # [3.0.0-rc.7](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.6...v3.0.0-rc.7) (2022-01-28)
108
+
109
+
110
+ ### Features
111
+
112
+ * **core:** replaced `Adapter` with `QuestionAdapter` and introduced `Optional` ([8d84ad3](https://github.com/serenity-js/serenity-js/commit/8d84ad3863e3c726533d0f21934fb1e2fa8b3022)), closes [#1103](https://github.com/serenity-js/serenity-js/issues/1103)
113
+
114
+
115
+
116
+ # [3.0.0-rc.6](https://github.com/serenity-js/serenity-js/compare/v2.32.7...v3.0.0-rc.6) (2022-01-10)
117
+
118
+
119
+
120
+ # [3.0.0-rc.5](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.4...v3.0.0-rc.5) (2022-01-07)
121
+
122
+
123
+
124
+ # [3.0.0-rc.4](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.3...v3.0.0-rc.4) (2021-12-30)
125
+
126
+
127
+ ### Bug Fixes
128
+
129
+ * **core:** you can now retrieve the .length property of an Array wrapped in an Adapter<Array> ([c36e210](https://github.com/serenity-js/serenity-js/commit/c36e210c024052b96ba47e9663c7098e269c5688))
130
+
131
+
132
+
133
+ # [3.0.0-rc.3](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.2...v3.0.0-rc.3) (2021-12-29)
134
+
135
+
136
+ ### Bug Fixes
137
+
138
+ * **rest:** corrected LastResponse to wrap .status(), .body(), .header() and .headers() in Adapters ([aab8e93](https://github.com/serenity-js/serenity-js/commit/aab8e93a19005710d9f333756cdae5aa21c31058)), closes [#1082](https://github.com/serenity-js/serenity-js/issues/1082)
139
+
140
+
141
+
142
+ # [3.0.0-rc.2](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.1...v3.0.0-rc.2) (2021-12-09)
143
+
144
+
145
+
6
146
  # [3.0.0-rc.1](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.0...v3.0.0-rc.1) (2021-12-09)
7
147
 
148
+
149
+
150
+ # [3.0.0-rc.0](https://github.com/serenity-js/serenity-js/compare/v2.32.5...v3.0.0-rc.0) (2021-12-08)
151
+
152
+
153
+ ### Bug Fixes
154
+
155
+ * **core:** 3.0 RC ([469d54e](https://github.com/serenity-js/serenity-js/commit/469d54e4f81ef430566b93852e3174826f8ef672)), closes [#805](https://github.com/serenity-js/serenity-js/issues/805)
156
+
157
+
158
+ ### Features
159
+
160
+ * **core:** question.about produces "props" that proxy the methods of the underlying model ([f771872](https://github.com/serenity-js/serenity-js/commit/f771872c56b487e404002c3800fc8f3baaed804f))
161
+
162
+
163
+ ### BREAKING CHANGES
164
+
165
+ * **core:** Introduced @serenity-js/web - a shared library for Serenity/JS Web integration
166
+ modules such as @serenity-js/protractor and @serenity-js/webdriverio. Dropped support for Node 12.
167
+
168
+
169
+
170
+
171
+
172
+ # [3.0.0-rc.10](https://github.com/serenity-js/serenity-js/compare/v2.33.0...v3.0.0-rc.10) (2022-02-03)
173
+
174
+
175
+
176
+ # [3.0.0-rc.9](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.8...v3.0.0-rc.9) (2022-02-01)
177
+
178
+
179
+
180
+ # [3.0.0-rc.8](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.7...v3.0.0-rc.8) (2022-01-28)
181
+
182
+
183
+
184
+ # [3.0.0-rc.7](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.6...v3.0.0-rc.7) (2022-01-28)
185
+
186
+
187
+ ### Features
188
+
189
+ * **core:** replaced `Adapter` with `QuestionAdapter` and introduced `Optional` ([8d84ad3](https://github.com/serenity-js/serenity-js/commit/8d84ad3863e3c726533d0f21934fb1e2fa8b3022)), closes [#1103](https://github.com/serenity-js/serenity-js/issues/1103)
190
+
191
+
192
+
193
+ # [3.0.0-rc.6](https://github.com/serenity-js/serenity-js/compare/v2.32.7...v3.0.0-rc.6) (2022-01-10)
194
+
195
+
196
+
197
+ # [3.0.0-rc.5](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.4...v3.0.0-rc.5) (2022-01-07)
198
+
199
+
200
+
201
+ # [3.0.0-rc.4](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.3...v3.0.0-rc.4) (2021-12-30)
202
+
203
+
204
+ ### Bug Fixes
205
+
206
+ * **core:** you can now retrieve the .length property of an Array wrapped in an Adapter<Array> ([c36e210](https://github.com/serenity-js/serenity-js/commit/c36e210c024052b96ba47e9663c7098e269c5688))
207
+
208
+
209
+
210
+ # [3.0.0-rc.3](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.2...v3.0.0-rc.3) (2021-12-29)
211
+
212
+
213
+ ### Bug Fixes
214
+
215
+ * **rest:** corrected LastResponse to wrap .status(), .body(), .header() and .headers() in Adapters ([aab8e93](https://github.com/serenity-js/serenity-js/commit/aab8e93a19005710d9f333756cdae5aa21c31058)), closes [#1082](https://github.com/serenity-js/serenity-js/issues/1082)
216
+
217
+
218
+
219
+ # [3.0.0-rc.2](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.1...v3.0.0-rc.2) (2021-12-09)
220
+
221
+
222
+
223
+ # [3.0.0-rc.1](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.0...v3.0.0-rc.1) (2021-12-09)
224
+
225
+
226
+
227
+ # [3.0.0-rc.0](https://github.com/serenity-js/serenity-js/compare/v2.32.5...v3.0.0-rc.0) (2021-12-08)
228
+
229
+
230
+ ### Bug Fixes
231
+
232
+ * **core:** 3.0 RC ([469d54e](https://github.com/serenity-js/serenity-js/commit/469d54e4f81ef430566b93852e3174826f8ef672)), closes [#805](https://github.com/serenity-js/serenity-js/issues/805)
233
+
234
+
235
+ ### Features
236
+
237
+ * **core:** question.about produces "props" that proxy the methods of the underlying model ([f771872](https://github.com/serenity-js/serenity-js/commit/f771872c56b487e404002c3800fc8f3baaed804f))
238
+
239
+
240
+ ### BREAKING CHANGES
241
+
242
+ * **core:** Introduced @serenity-js/web - a shared library for Serenity/JS Web integration
243
+ modules such as @serenity-js/protractor and @serenity-js/webdriverio. Dropped support for Node 12.
244
+
245
+
246
+
247
+
248
+
249
+ # [3.0.0-rc.9](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.8...v3.0.0-rc.9) (2022-02-01)
250
+
8
251
  **Note:** Version bump only for package @serenity-js/rest
9
252
 
10
253
 
11
254
 
12
255
 
13
256
 
257
+ # [3.0.0-rc.8](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.7...v3.0.0-rc.8) (2022-01-28)
258
+
259
+ **Note:** Version bump only for package @serenity-js/rest
260
+
261
+
262
+
263
+
264
+
265
+ # [3.0.0-rc.7](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.6...v3.0.0-rc.7) (2022-01-28)
266
+
267
+
268
+ ### Features
269
+
270
+ * **core:** replaced `Adapter` with `QuestionAdapter` and introduced `Optional` ([8d84ad3](https://github.com/serenity-js/serenity-js/commit/8d84ad3863e3c726533d0f21934fb1e2fa8b3022)), closes [#1103](https://github.com/serenity-js/serenity-js/issues/1103)
271
+
272
+
273
+
274
+
275
+
276
+ # [3.0.0-rc.6](https://github.com/serenity-js/serenity-js/compare/v2.32.7...v3.0.0-rc.6) (2022-01-10)
277
+
278
+
279
+
280
+ # [3.0.0-rc.5](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.4...v3.0.0-rc.5) (2022-01-07)
281
+
282
+
283
+
284
+ # [3.0.0-rc.4](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.3...v3.0.0-rc.4) (2021-12-30)
285
+
286
+
287
+ ### Bug Fixes
288
+
289
+ * **core:** you can now retrieve the .length property of an Array wrapped in an Adapter<Array> ([c36e210](https://github.com/serenity-js/serenity-js/commit/c36e210c024052b96ba47e9663c7098e269c5688))
290
+
291
+
292
+
293
+ # [3.0.0-rc.3](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.2...v3.0.0-rc.3) (2021-12-29)
294
+
295
+
296
+ ### Bug Fixes
297
+
298
+ * **rest:** corrected LastResponse to wrap .status(), .body(), .header() and .headers() in Adapters ([aab8e93](https://github.com/serenity-js/serenity-js/commit/aab8e93a19005710d9f333756cdae5aa21c31058)), closes [#1082](https://github.com/serenity-js/serenity-js/issues/1082)
299
+
300
+
301
+
302
+ # [3.0.0-rc.2](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.1...v3.0.0-rc.2) (2021-12-09)
303
+
304
+
305
+
306
+ # [3.0.0-rc.1](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.0...v3.0.0-rc.1) (2021-12-09)
307
+
308
+
309
+
14
310
  # [3.0.0-rc.0](https://github.com/serenity-js/serenity-js/compare/v2.32.5...v3.0.0-rc.0) (2021-12-08)
15
311
 
16
312
 
@@ -33,6 +329,114 @@ modules such as @serenity-js/protractor and @serenity-js/webdriverio. Dropped su
33
329
 
34
330
 
35
331
 
332
+ # [3.0.0-rc.5](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.4...v3.0.0-rc.5) (2022-01-07)
333
+
334
+ **Note:** Version bump only for package @serenity-js/rest
335
+
336
+
337
+
338
+
339
+
340
+ # [3.0.0-rc.4](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.3...v3.0.0-rc.4) (2021-12-30)
341
+
342
+
343
+ ### Bug Fixes
344
+
345
+ * **core:** you can now retrieve the .length property of an Array wrapped in an Adapter<Array> ([c36e210](https://github.com/serenity-js/serenity-js/commit/c36e210c024052b96ba47e9663c7098e269c5688))
346
+
347
+
348
+
349
+
350
+
351
+ # [3.0.0-rc.3](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.2...v3.0.0-rc.3) (2021-12-29)
352
+
353
+
354
+ ### Bug Fixes
355
+
356
+ * **rest:** corrected LastResponse to wrap .status(), .body(), .header() and .headers() in Adapters ([aab8e93](https://github.com/serenity-js/serenity-js/commit/aab8e93a19005710d9f333756cdae5aa21c31058)), closes [#1082](https://github.com/serenity-js/serenity-js/issues/1082)
357
+
358
+
359
+
360
+
361
+
362
+ # [3.0.0-rc.2](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.1...v3.0.0-rc.2) (2021-12-09)
363
+
364
+ **Note:** Version bump only for package @serenity-js/rest
365
+
366
+
367
+
368
+
369
+
370
+ # [3.0.0-rc.1](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.0...v3.0.0-rc.1) (2021-12-09)
371
+
372
+ **Note:** Version bump only for package @serenity-js/rest
373
+
374
+
375
+
376
+
377
+
378
+ # [3.0.0-rc.0](https://github.com/serenity-js/serenity-js/compare/v2.32.5...v3.0.0-rc.0) (2021-12-08)
379
+
380
+
381
+ ### Bug Fixes
382
+
383
+ * **core:** 3.0 RC ([469d54e](https://github.com/serenity-js/serenity-js/commit/469d54e4f81ef430566b93852e3174826f8ef672)), closes [#805](https://github.com/serenity-js/serenity-js/issues/805)
384
+
385
+
386
+ ### Features
387
+
388
+ * **core:** question.about produces "props" that proxy the methods of the underlying model ([f771872](https://github.com/serenity-js/serenity-js/commit/f771872c56b487e404002c3800fc8f3baaed804f))
389
+
390
+
391
+ ### BREAKING CHANGES
392
+
393
+ * **core:** Introduced @serenity-js/web - a shared library for Serenity/JS Web integration
394
+ modules such as @serenity-js/protractor and @serenity-js/webdriverio. Dropped support for Node 12.
395
+
396
+
397
+
398
+
399
+
400
+ ## [2.33.2](https://github.com/serenity-js/serenity-js/compare/v2.33.1...v2.33.2) (2022-02-23)
401
+
402
+ **Note:** Version bump only for package @serenity-js/rest
403
+
404
+
405
+
406
+
407
+
408
+ ## [2.33.1](https://github.com/serenity-js/serenity-js/compare/v2.33.0...v2.33.1) (2022-02-10)
409
+
410
+ **Note:** Version bump only for package @serenity-js/rest
411
+
412
+
413
+
414
+
415
+
416
+ # [2.33.0](https://github.com/serenity-js/serenity-js/compare/v2.32.7...v2.33.0) (2022-02-03)
417
+
418
+ **Note:** Version bump only for package @serenity-js/rest
419
+
420
+
421
+
422
+
423
+
424
+ ## [2.32.7](https://github.com/serenity-js/serenity-js/compare/v2.32.6...v2.32.7) (2022-01-10)
425
+
426
+ **Note:** Version bump only for package @serenity-js/rest
427
+
428
+
429
+
430
+
431
+
432
+ ## [2.32.6](https://github.com/serenity-js/serenity-js/compare/v2.32.5...v2.32.6) (2022-01-10)
433
+
434
+ **Note:** Version bump only for package @serenity-js/rest
435
+
436
+
437
+
438
+
439
+
36
440
  ## [2.32.5](https://github.com/serenity-js/serenity-js/compare/v2.32.4...v2.32.5) (2021-12-08)
37
441
 
38
442
  **Note:** Version bump only for package @serenity-js/rest
@@ -1,4 +1,4 @@
1
- import { Question } from '@serenity-js/core';
1
+ import { QuestionAdapter } from '@serenity-js/core';
2
2
  /**
3
3
  * @desc
4
4
  * Provides access to the properties of the last {@link AxiosResponse} object,
@@ -25,6 +25,31 @@ import { Question } from '@serenity-js/core';
25
25
  * author: 'Robert M. Pirsig',
26
26
  * })),
27
27
  * );
28
+ *
29
+ * @example <caption>Use Serenity/JS adapters to navigate complex response objects</caption>
30
+ * import { Actor } from '@serenity-js/core';
31
+ * import { CallAnApi, GetRequest, LastResponse, Send } from '@serenity-js/rest'
32
+ * import { Ensure, equals } from '@serenity-js/assertions';
33
+ *
34
+ * interface Developer {
35
+ * name: string;
36
+ * id: string;
37
+ * projects: Project[];
38
+ * }
39
+ *
40
+ * interface Project {
41
+ * name: string;
42
+ * repoUrl: string;
43
+ * }
44
+ *
45
+ * const actor = Actor.named('Apisit').whoCan(CallAnApi.at('https://myapp.com/api'));
46
+ *
47
+ * actor.attemptsTo(
48
+ * Send.a(GetRequest.to('/developers/jan-molak')),
49
+ * Ensure.that(LastResponse.status(), equals(200)),
50
+ * Ensure.that(LastResponse.body<Developer>().name, equals('Jan Molak')),
51
+ * Ensure.that(LastResponse.body<Developer>().projects[0].name, equals('Serenity/JS')),
52
+ * );
28
53
  */
29
54
  export declare class LastResponse {
30
55
  /**
@@ -33,7 +58,7 @@ export declare class LastResponse {
33
58
  *
34
59
  * @returns {@serenity-js/core/lib/screenplay~Question<number>}
35
60
  */
36
- static status(): Question<number>;
61
+ static status(): QuestionAdapter<number>;
37
62
  /**
38
63
  * @desc
39
64
  * Enables asserting on the {@link LastResponse} body
@@ -90,7 +115,7 @@ export declare class LastResponse {
90
115
  * @see {@link @serenity-js/core/lib/screenplay/questions~Property}
91
116
  * @see {@link @serenity-js/core/lib/screenplay/questions~List}
92
117
  */
93
- static body<T = any>(): Question<T>;
118
+ static body<T = any>(): QuestionAdapter<T>;
94
119
  /**
95
120
  * @desc
96
121
  * Enables asserting on one of the {@link LastResponse}'s headers
@@ -98,7 +123,7 @@ export declare class LastResponse {
98
123
  * @param {string} name
99
124
  * @returns {@serenity-js/core/lib/screenplay~Question<string>}
100
125
  */
101
- static header(name: string): Question<string>;
126
+ static header(name: string): QuestionAdapter<string>;
102
127
  /**
103
128
  * @desc
104
129
  * Enables asserting on all of the {@link LastResponse}'s headers,
@@ -106,5 +131,5 @@ export declare class LastResponse {
106
131
  *
107
132
  * @returns {@serenity-js/core/lib/screenplay~Question<Record<string, string>>}
108
133
  */
109
- static headers(): Question<Record<string, string>>;
134
+ static headers(): QuestionAdapter<Record<string, string>>;
110
135
  }
@@ -29,6 +29,31 @@ const abilities_1 = require("../abilities");
29
29
  * author: 'Robert M. Pirsig',
30
30
  * })),
31
31
  * );
32
+ *
33
+ * @example <caption>Use Serenity/JS adapters to navigate complex response objects</caption>
34
+ * import { Actor } from '@serenity-js/core';
35
+ * import { CallAnApi, GetRequest, LastResponse, Send } from '@serenity-js/rest'
36
+ * import { Ensure, equals } from '@serenity-js/assertions';
37
+ *
38
+ * interface Developer {
39
+ * name: string;
40
+ * id: string;
41
+ * projects: Project[];
42
+ * }
43
+ *
44
+ * interface Project {
45
+ * name: string;
46
+ * repoUrl: string;
47
+ * }
48
+ *
49
+ * const actor = Actor.named('Apisit').whoCan(CallAnApi.at('https://myapp.com/api'));
50
+ *
51
+ * actor.attemptsTo(
52
+ * Send.a(GetRequest.to('/developers/jan-molak')),
53
+ * Ensure.that(LastResponse.status(), equals(200)),
54
+ * Ensure.that(LastResponse.body<Developer>().name, equals('Jan Molak')),
55
+ * Ensure.that(LastResponse.body<Developer>().projects[0].name, equals('Serenity/JS')),
56
+ * );
32
57
  */
33
58
  class LastResponse {
34
59
  /**
@@ -38,7 +63,7 @@ class LastResponse {
38
63
  * @returns {@serenity-js/core/lib/screenplay~Question<number>}
39
64
  */
40
65
  static status() {
41
- return core_1.Question.about(`the status of the last response`, actor => {
66
+ return core_1.Question.about(`the status of the last response`, async (actor) => {
42
67
  return abilities_1.CallAnApi.as(actor).mapLastResponse(response => response.status);
43
68
  });
44
69
  }
@@ -99,7 +124,7 @@ class LastResponse {
99
124
  * @see {@link @serenity-js/core/lib/screenplay/questions~List}
100
125
  */
101
126
  static body() {
102
- return core_1.Question.about(`the body of the last response`, actor => {
127
+ return core_1.Question.about(`the body of the last response`, async (actor) => {
103
128
  return abilities_1.CallAnApi.as(actor).mapLastResponse(response => response.data);
104
129
  });
105
130
  }
@@ -111,7 +136,7 @@ class LastResponse {
111
136
  * @returns {@serenity-js/core/lib/screenplay~Question<string>}
112
137
  */
113
138
  static header(name) {
114
- return core_1.Question.about(`the '${name}' header of the last response`, actor => {
139
+ return core_1.Question.about(`the '${name}' header of the last response`, async (actor) => {
115
140
  return abilities_1.CallAnApi.as(actor).mapLastResponse(response => response.headers[name]);
116
141
  });
117
142
  }
@@ -123,7 +148,7 @@ class LastResponse {
123
148
  * @returns {@serenity-js/core/lib/screenplay~Question<Record<string, string>>}
124
149
  */
125
150
  static headers() {
126
- return core_1.Question.about(`the headers or the last response`, actor => {
151
+ return core_1.Question.about(`the headers or the last response`, async (actor) => {
127
152
  return abilities_1.CallAnApi.as(actor).mapLastResponse(response => response.headers);
128
153
  });
129
154
  }
@@ -1 +1 @@
1
- {"version":3,"file":"LastResponse.js","sourceRoot":"","sources":["../../../src/screenplay/questions/LastResponse.ts"],"names":[],"mappings":";;;AAAA,4CAA6C;AAE7C,4CAAyC;AAEzC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAa,YAAY;IAErB;;;;;OAKG;IACH,MAAM,CAAC,MAAM;QACT,OAAO,eAAQ,CAAC,KAAK,CAAS,iCAAiC,EAAE,KAAK,CAAC,EAAE;YACrE,OAAO,qBAAS,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAC5E,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAuDG;IACH,MAAM,CAAC,IAAI;QACP,OAAO,eAAQ,CAAC,KAAK,CAAI,+BAA+B,EAAE,KAAK,CAAC,EAAE;YAC9D,OAAO,qBAAS,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,eAAe,CAAI,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAS,CAAC,CAAC;QAClF,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,MAAM,CAAC,IAAY;QACtB,OAAO,eAAQ,CAAC,KAAK,CAAS,QAAS,IAAK,+BAA+B,EAAE,KAAK,CAAC,EAAE;YACjF,OAAO,qBAAS,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QACnF,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,OAAO;QACV,OAAO,eAAQ,CAAC,KAAK,CAAyB,kCAAkC,EAAE,KAAK,CAAC,EAAE;YACtF,OAAO,qBAAS,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC7E,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AArGD,oCAqGC"}
1
+ {"version":3,"file":"LastResponse.js","sourceRoot":"","sources":["../../../src/screenplay/questions/LastResponse.ts"],"names":[],"mappings":";;;AAAA,4CAA8D;AAE9D,4CAAyC;AAEzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,MAAa,YAAY;IAErB;;;;;OAKG;IACH,MAAM,CAAC,MAAM;QACT,OAAO,eAAQ,CAAC,KAAK,CAAS,iCAAiC,EAAE,KAAK,EAAC,KAAK,EAAC,EAAE;YAC3E,OAAO,qBAAS,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAC5E,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAuDG;IACH,MAAM,CAAC,IAAI;QACP,OAAO,eAAQ,CAAC,KAAK,CAAI,+BAA+B,EAAE,KAAK,EAAC,KAAK,EAAC,EAAE;YACpE,OAAO,qBAAS,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,eAAe,CAAI,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAS,CAAC,CAAC;QAClF,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,MAAM,CAAC,IAAY;QACtB,OAAO,eAAQ,CAAC,KAAK,CAAS,QAAS,IAAK,+BAA+B,EAAE,KAAK,EAAC,KAAK,EAAC,EAAE;YACvF,OAAO,qBAAS,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QACnF,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,OAAO;QACV,OAAO,eAAQ,CAAC,KAAK,CAAyB,kCAAkC,EAAE,KAAK,EAAC,KAAK,EAAC,EAAE;YAC5F,OAAO,qBAAS,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC7E,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AArGD,oCAqGC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@serenity-js/rest",
3
- "version": "3.0.0-rc.1",
3
+ "version": "3.0.0-rc.12",
4
4
  "description": "Test REST APIs with Serenity/JS",
5
5
  "author": {
6
6
  "name": "Jan Molak",
@@ -47,19 +47,19 @@
47
47
  "npm": "^6 || ^7 || ^8"
48
48
  },
49
49
  "dependencies": {
50
- "@serenity-js/core": "3.0.0-rc.1",
50
+ "@serenity-js/core": "3.0.0-rc.12",
51
51
  "axios": "^0.21.4"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@documentation/esdoc-template": "3.0.0",
55
55
  "@integration/testing-tools": "3.0.0",
56
- "@serenity-js/assertions": "3.0.0-rc.1",
56
+ "@serenity-js/assertions": "3.0.0-rc.12",
57
57
  "@types/chai": "^4.3.0",
58
- "@types/mocha": "^9.0.0",
58
+ "@types/mocha": "^9.1.0",
59
59
  "axios-mock-adapter": "^1.20.0",
60
- "mocha": "^9.1.3",
61
- "ts-node": "^10.4.0",
62
- "typescript": "^4.5.2"
60
+ "mocha": "^9.2.1",
61
+ "ts-node": "^10.5.0",
62
+ "typescript": "^4.5.5"
63
63
  },
64
64
  "nyc": {
65
65
  "include": [
@@ -83,5 +83,5 @@
83
83
  "cache": true,
84
84
  "all": true
85
85
  },
86
- "gitHead": "ceed4ad3a2375c14b0546a6fc2fe3e816250f746"
86
+ "gitHead": "5bb8519ef9a91180860675384cfb99ad793a4263"
87
87
  }
@@ -1,4 +1,4 @@
1
- import { Question } from '@serenity-js/core';
1
+ import { Question, QuestionAdapter } from '@serenity-js/core';
2
2
 
3
3
  import { CallAnApi } from '../abilities';
4
4
 
@@ -28,6 +28,31 @@ import { CallAnApi } from '../abilities';
28
28
  * author: 'Robert M. Pirsig',
29
29
  * })),
30
30
  * );
31
+ *
32
+ * @example <caption>Use Serenity/JS adapters to navigate complex response objects</caption>
33
+ * import { Actor } from '@serenity-js/core';
34
+ * import { CallAnApi, GetRequest, LastResponse, Send } from '@serenity-js/rest'
35
+ * import { Ensure, equals } from '@serenity-js/assertions';
36
+ *
37
+ * interface Developer {
38
+ * name: string;
39
+ * id: string;
40
+ * projects: Project[];
41
+ * }
42
+ *
43
+ * interface Project {
44
+ * name: string;
45
+ * repoUrl: string;
46
+ * }
47
+ *
48
+ * const actor = Actor.named('Apisit').whoCan(CallAnApi.at('https://myapp.com/api'));
49
+ *
50
+ * actor.attemptsTo(
51
+ * Send.a(GetRequest.to('/developers/jan-molak')),
52
+ * Ensure.that(LastResponse.status(), equals(200)),
53
+ * Ensure.that(LastResponse.body<Developer>().name, equals('Jan Molak')),
54
+ * Ensure.that(LastResponse.body<Developer>().projects[0].name, equals('Serenity/JS')),
55
+ * );
31
56
  */
32
57
  export class LastResponse {
33
58
 
@@ -37,8 +62,8 @@ export class LastResponse {
37
62
  *
38
63
  * @returns {@serenity-js/core/lib/screenplay~Question<number>}
39
64
  */
40
- static status(): Question<number> {
41
- return Question.about<number>(`the status of the last response`, actor => {
65
+ static status(): QuestionAdapter<number> {
66
+ return Question.about<number>(`the status of the last response`, async actor => {
42
67
  return CallAnApi.as(actor).mapLastResponse(response => response.status);
43
68
  });
44
69
  }
@@ -99,8 +124,8 @@ export class LastResponse {
99
124
  * @see {@link @serenity-js/core/lib/screenplay/questions~Property}
100
125
  * @see {@link @serenity-js/core/lib/screenplay/questions~List}
101
126
  */
102
- static body<T = any>(): Question<T> {
103
- return Question.about<T>(`the body of the last response`, actor => {
127
+ static body<T = any>(): QuestionAdapter<T> {
128
+ return Question.about<T>(`the body of the last response`, async actor => {
104
129
  return CallAnApi.as(actor).mapLastResponse<T>(response => response.data as T);
105
130
  });
106
131
  }
@@ -112,8 +137,8 @@ export class LastResponse {
112
137
  * @param {string} name
113
138
  * @returns {@serenity-js/core/lib/screenplay~Question<string>}
114
139
  */
115
- static header(name: string): Question<string> {
116
- return Question.about<string>(`the '${ name }' header of the last response`, actor => {
140
+ static header(name: string): QuestionAdapter<string> {
141
+ return Question.about<string>(`the '${ name }' header of the last response`, async actor => {
117
142
  return CallAnApi.as(actor).mapLastResponse(response => response.headers[name]);
118
143
  });
119
144
  }
@@ -125,8 +150,8 @@ export class LastResponse {
125
150
  *
126
151
  * @returns {@serenity-js/core/lib/screenplay~Question<Record<string, string>>}
127
152
  */
128
- static headers(): Question<Record<string, string>> {
129
- return Question.about<Record<string, string>>(`the headers or the last response`, actor => {
153
+ static headers(): QuestionAdapter<Record<string, string>> {
154
+ return Question.about<Record<string, string>>(`the headers or the last response`, async actor => {
130
155
  return CallAnApi.as(actor).mapLastResponse(response => response.headers);
131
156
  });
132
157
  }