@serenity-js/core 2.32.2 → 3.0.0-rc.0
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 +64 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +4 -1
- package/lib/index.js.map +1 -1
- package/lib/io/ErrorSerialiser.js +4 -1
- package/lib/io/ErrorSerialiser.js.map +1 -1
- package/lib/io/collections/index.d.ts +0 -1
- package/lib/io/collections/index.js +0 -1
- package/lib/io/collections/index.js.map +1 -1
- package/lib/io/format.d.ts +37 -0
- package/lib/io/format.js +49 -0
- package/lib/io/format.js.map +1 -0
- package/lib/io/formatted.d.ts +5 -1
- package/lib/io/formatted.js +6 -13
- package/lib/io/formatted.js.map +1 -1
- package/lib/io/index.d.ts +1 -0
- package/lib/io/index.js +1 -0
- package/lib/io/index.js.map +1 -1
- package/lib/io/inspected.d.ts +9 -1
- package/lib/io/inspected.js +50 -14
- package/lib/io/inspected.js.map +1 -1
- package/lib/model/Timestamp.d.ts +4 -2
- package/lib/model/Timestamp.js +8 -2
- package/lib/model/Timestamp.js.map +1 -1
- package/lib/screenplay/Question.d.ts +6 -83
- package/lib/screenplay/Question.js +14 -98
- package/lib/screenplay/Question.js.map +1 -1
- package/lib/screenplay/actor/Actor.js +2 -2
- package/lib/screenplay/actor/Actor.js.map +1 -1
- package/lib/screenplay/index.d.ts +1 -1
- package/lib/screenplay/index.js +1 -1
- package/lib/screenplay/index.js.map +1 -1
- package/lib/screenplay/model/Adapter.d.ts +8 -0
- package/lib/screenplay/{questions/proxies/PropertyPathKey.js → model/Adapter.js} +1 -1
- package/lib/screenplay/model/Adapter.js.map +1 -0
- package/lib/screenplay/model/createAdapter.d.ts +3 -0
- package/lib/screenplay/model/createAdapter.js +112 -0
- package/lib/screenplay/model/createAdapter.js.map +1 -0
- package/lib/screenplay/model/index.d.ts +2 -0
- package/lib/screenplay/{tasks → model}/index.js +2 -1
- package/lib/screenplay/model/index.js.map +1 -0
- package/lib/screenplay/questions/Expectation.d.ts +11 -0
- package/lib/screenplay/questions/Expectation.js +18 -1
- package/lib/screenplay/questions/Expectation.js.map +1 -1
- package/lib/screenplay/questions/List.d.ts +10 -0
- package/lib/screenplay/questions/List.js +16 -1
- package/lib/screenplay/questions/List.js.map +1 -1
- package/lib/screenplay/questions/Note.d.ts +10 -0
- package/lib/screenplay/questions/Note.js +17 -1
- package/lib/screenplay/questions/Note.js.map +1 -1
- package/lib/screenplay/questions/index.d.ts +0 -3
- package/lib/screenplay/questions/index.js +0 -5
- package/lib/screenplay/questions/index.js.map +1 -1
- package/lib/screenplay/questions/lists/ArrayListAdapter.js +20 -5
- package/lib/screenplay/questions/lists/ArrayListAdapter.js.map +1 -1
- package/package.json +10 -10
- package/src/index.ts +2 -1
- package/src/io/ErrorSerialiser.ts +5 -1
- package/src/io/collections/index.ts +0 -1
- package/src/io/format.ts +46 -0
- package/src/io/formatted.ts +7 -15
- package/src/io/index.ts +1 -0
- package/src/io/inspected.ts +66 -14
- package/src/model/Timestamp.ts +10 -2
- package/src/screenplay/Question.ts +21 -119
- package/src/screenplay/actor/Actor.ts +2 -2
- package/src/screenplay/index.ts +1 -1
- package/src/screenplay/model/Adapter.ts +14 -0
- package/src/screenplay/model/createAdapter.ts +142 -0
- package/src/screenplay/model/index.ts +2 -0
- package/src/screenplay/questions/Expectation.ts +20 -1
- package/src/screenplay/questions/List.ts +19 -1
- package/src/screenplay/questions/Note.ts +21 -1
- package/src/screenplay/questions/index.ts +0 -3
- package/src/screenplay/questions/lists/ArrayListAdapter.ts +21 -2
- package/lib/decorators/pending.d.ts +0 -0
- package/lib/decorators/pending.js +0 -2
- package/lib/decorators/pending.js.map +0 -1
- package/lib/decorators/step.d.ts +0 -0
- package/lib/decorators/step.js +0 -2
- package/lib/decorators/step.js.map +0 -1
- package/lib/io/collections/mappable.d.ts +0 -52
- package/lib/io/collections/mappable.js +0 -28
- package/lib/io/collections/mappable.js.map +0 -1
- package/lib/screenplay/questions/Property.d.ts +0 -91
- package/lib/screenplay/questions/Property.js +0 -99
- package/lib/screenplay/questions/Property.js.map +0 -1
- package/lib/screenplay/questions/Transform.d.ts +0 -31
- package/lib/screenplay/questions/Transform.js +0 -46
- package/lib/screenplay/questions/Transform.js.map +0 -1
- package/lib/screenplay/questions/mappings/AnswerMappingFunction.d.ts +0 -11
- package/lib/screenplay/questions/mappings/AnswerMappingFunction.js +0 -3
- package/lib/screenplay/questions/mappings/AnswerMappingFunction.js.map +0 -1
- package/lib/screenplay/questions/mappings/index.d.ts +0 -2
- package/lib/screenplay/questions/mappings/index.js +0 -15
- package/lib/screenplay/questions/mappings/index.js.map +0 -1
- package/lib/screenplay/questions/mappings/string/append.d.ts +0 -14
- package/lib/screenplay/questions/mappings/string/append.js +0 -25
- package/lib/screenplay/questions/mappings/string/append.js.map +0 -1
- package/lib/screenplay/questions/mappings/string/index.d.ts +0 -11
- package/lib/screenplay/questions/mappings/string/index.js +0 -24
- package/lib/screenplay/questions/mappings/string/index.js.map +0 -1
- package/lib/screenplay/questions/mappings/string/normalize.d.ts +0 -20
- package/lib/screenplay/questions/mappings/string/normalize.js +0 -30
- package/lib/screenplay/questions/mappings/string/normalize.js.map +0 -1
- package/lib/screenplay/questions/mappings/string/replace.d.ts +0 -17
- package/lib/screenplay/questions/mappings/string/replace.js +0 -30
- package/lib/screenplay/questions/mappings/string/replace.js.map +0 -1
- package/lib/screenplay/questions/mappings/string/slice.d.ts +0 -28
- package/lib/screenplay/questions/mappings/string/slice.js +0 -47
- package/lib/screenplay/questions/mappings/string/slice.js.map +0 -1
- package/lib/screenplay/questions/mappings/string/split.d.ts +0 -19
- package/lib/screenplay/questions/mappings/string/split.js +0 -36
- package/lib/screenplay/questions/mappings/string/split.js.map +0 -1
- package/lib/screenplay/questions/mappings/string/toLocaleLowerCase.d.ts +0 -17
- package/lib/screenplay/questions/mappings/string/toLocaleLowerCase.js +0 -28
- package/lib/screenplay/questions/mappings/string/toLocaleLowerCase.js.map +0 -1
- package/lib/screenplay/questions/mappings/string/toLocaleUpperCase.d.ts +0 -17
- package/lib/screenplay/questions/mappings/string/toLocaleUpperCase.js +0 -29
- package/lib/screenplay/questions/mappings/string/toLocaleUpperCase.js.map +0 -1
- package/lib/screenplay/questions/mappings/string/toLowerCase.d.ts +0 -10
- package/lib/screenplay/questions/mappings/string/toLowerCase.js +0 -19
- package/lib/screenplay/questions/mappings/string/toLowerCase.js.map +0 -1
- package/lib/screenplay/questions/mappings/string/toNumber.d.ts +0 -10
- package/lib/screenplay/questions/mappings/string/toNumber.js +0 -18
- package/lib/screenplay/questions/mappings/string/toNumber.js.map +0 -1
- package/lib/screenplay/questions/mappings/string/toUpperCase.d.ts +0 -10
- package/lib/screenplay/questions/mappings/string/toUpperCase.js +0 -19
- package/lib/screenplay/questions/mappings/string/toUpperCase.js.map +0 -1
- package/lib/screenplay/questions/mappings/string/trim.d.ts +0 -12
- package/lib/screenplay/questions/mappings/string/trim.js +0 -21
- package/lib/screenplay/questions/mappings/string/trim.js.map +0 -1
- package/lib/screenplay/questions/proxies/PropertyPathKey.d.ts +0 -4
- package/lib/screenplay/questions/proxies/PropertyPathKey.js.map +0 -1
- package/lib/screenplay/questions/proxies/createMetaQuestionProxy.d.ts +0 -14
- package/lib/screenplay/questions/proxies/createMetaQuestionProxy.js +0 -35
- package/lib/screenplay/questions/proxies/createMetaQuestionProxy.js.map +0 -1
- package/lib/screenplay/questions/proxies/createQuestionProxy.d.ts +0 -13
- package/lib/screenplay/questions/proxies/createQuestionProxy.js +0 -34
- package/lib/screenplay/questions/proxies/createQuestionProxy.js.map +0 -1
- package/lib/screenplay/questions/proxies/describePath.d.ts +0 -5
- package/lib/screenplay/questions/proxies/describePath.js +0 -19
- package/lib/screenplay/questions/proxies/describePath.js.map +0 -1
- package/lib/screenplay/questions/proxies/index.d.ts +0 -2
- package/lib/screenplay/questions/proxies/index.js +0 -15
- package/lib/screenplay/questions/proxies/index.js.map +0 -1
- package/lib/screenplay/questions/proxies/key.d.ts +0 -8
- package/lib/screenplay/questions/proxies/key.js +0 -16
- package/lib/screenplay/questions/proxies/key.js.map +0 -1
- package/lib/screenplay/tasks/Loop.d.ts +0 -198
- package/lib/screenplay/tasks/Loop.js +0 -222
- package/lib/screenplay/tasks/Loop.js.map +0 -1
- package/lib/screenplay/tasks/index.d.ts +0 -1
- package/lib/screenplay/tasks/index.js.map +0 -1
- package/src/decorators/pending.ts +0 -1
- package/src/decorators/step.ts +0 -1
- package/src/io/collections/mappable.ts +0 -60
- package/src/screenplay/questions/Property.ts +0 -98
- package/src/screenplay/questions/Transform.ts +0 -50
- package/src/screenplay/questions/mappings/AnswerMappingFunction.ts +0 -13
- package/src/screenplay/questions/mappings/index.ts +0 -2
- package/src/screenplay/questions/mappings/string/append.ts +0 -28
- package/src/screenplay/questions/mappings/string/index.ts +0 -11
- package/src/screenplay/questions/mappings/string/normalize.ts +0 -33
- package/src/screenplay/questions/mappings/string/replace.ts +0 -34
- package/src/screenplay/questions/mappings/string/slice.ts +0 -53
- package/src/screenplay/questions/mappings/string/split.ts +0 -38
- package/src/screenplay/questions/mappings/string/toLocaleLowerCase.ts +0 -31
- package/src/screenplay/questions/mappings/string/toLocaleUpperCase.ts +0 -30
- package/src/screenplay/questions/mappings/string/toLowerCase.ts +0 -20
- package/src/screenplay/questions/mappings/string/toNumber.ts +0 -19
- package/src/screenplay/questions/mappings/string/toUpperCase.ts +0 -20
- package/src/screenplay/questions/mappings/string/trim.ts +0 -22
- package/src/screenplay/questions/proxies/PropertyPathKey.ts +0 -4
- package/src/screenplay/questions/proxies/createMetaQuestionProxy.ts +0 -51
- package/src/screenplay/questions/proxies/createQuestionProxy.ts +0 -49
- package/src/screenplay/questions/proxies/describePath.ts +0 -23
- package/src/screenplay/questions/proxies/index.ts +0 -2
- package/src/screenplay/questions/proxies/key.ts +0 -14
- package/src/screenplay/tasks/Loop.ts +0 -240
- package/src/screenplay/tasks/index.ts +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"List.js","sourceRoot":"","sources":["../../../src/screenplay/questions/List.ts"],"names":[],"mappings":";;;AAAA,iCAAqC;AAGrC,0CAAuC;AAEvC,mCAAwD;AAGxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,MAAa,IAOT,SAAQ,mBAAgC;
|
|
1
|
+
{"version":3,"file":"List.js","sourceRoot":"","sources":["../../../src/screenplay/questions/List.ts"],"names":[],"mappings":";;;AAAA,iCAAqC;AAGrC,0CAAuC;AAEvC,mCAAwD;AAGxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,MAAa,IAOT,SAAQ,mBAAgC;IAuBxC;;OAEG;IACH,YAA6B,UAA6B;QACtD,KAAK,EAAE,CAAC;QADiB,eAAU,GAAV,UAAU,CAAmB;QAEtD,IAAI,CAAC,OAAO,GAAG,IAAA,cAAS,EAAA,GAAI,UAAW,EAAE,CAAC;IAC9C,CAAC;IAzBD;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,EAAE,CAAY,KAA8B;QAC/C,OAAO,IAAI,IAAI,CACX,IAAI,wBAAgB,CAAC,KAAK,CAAC,CAC9B,CAAC;IACN,CAAC;IAUD;;;;;;;;;;;;;;;;;;OAkBG;IACH,KAAK;QACD,OAAO,mBAAQ,CAAC,KAAK,CAAC,iBAAkB,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAG,EAAE,EAAE,KAAK,CAAC,EAAE,CAC3E,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAC/B,CAAC;IACN,CAAC;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,KAAK;QACD,OAAO,mBAAQ,CAAC,KAAK,CAAC,gBAAiB,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAG,EAAE,EAAE,KAAK,CAAC,EAAE,CAC1E,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,CA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AAI,aAAa,KAAK,EAAE,CAAC;gBAC1C,OAAO,KAAK,GAAG,IAAI,CAAC;YACxB,KAAK,CAAC,SAAS,KAAK,CAAC,IAAI,aAAa,KAAK,EAAE,CAAC;gBAC1C,OAAO,KAAK,GAAG,IAAI,CAAC;YACxB,KAAK,CAAC,SAAS,KAAK,CAAC,IAAI,aAAa,KAAK,EAAE,CAAC;gBAC1C,OAAO,KAAK,GAAG,IAAI,CAAC;YACxB;gBACI,OAAO,KAAK,GAAG,IAAI,CAAC;SAC3B;IACL,CAAC;CACJ;AA5ND,oBA4NC"}
|
|
@@ -40,6 +40,7 @@ import { Question } from '../Question';
|
|
|
40
40
|
*/
|
|
41
41
|
export declare class Note<Answer> extends Question<Promise<Answer>> {
|
|
42
42
|
private readonly topic;
|
|
43
|
+
private subject;
|
|
43
44
|
/**
|
|
44
45
|
* @desc
|
|
45
46
|
* Retrieves the previously recorded answer to a given {@link Question}
|
|
@@ -66,4 +67,13 @@ export declare class Note<Answer> extends Question<Promise<Answer>> {
|
|
|
66
67
|
* @see {@link UsesAbilities}
|
|
67
68
|
*/
|
|
68
69
|
answeredBy(actor: AnswersQuestions & UsesAbilities): Promise<Answer>;
|
|
70
|
+
/**
|
|
71
|
+
* @desc
|
|
72
|
+
* Changes the description of this question's subject.
|
|
73
|
+
*
|
|
74
|
+
* @param {string} subject
|
|
75
|
+
* @returns {Question<T>}
|
|
76
|
+
*/
|
|
77
|
+
describedAs(subject: string): this;
|
|
78
|
+
toString(): string;
|
|
69
79
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Note = void 0;
|
|
4
|
+
const io_1 = require("../../io");
|
|
4
5
|
const abilities_1 = require("../abilities");
|
|
5
6
|
const Question_1 = require("../Question");
|
|
6
7
|
/**
|
|
@@ -46,8 +47,9 @@ class Note extends Question_1.Question {
|
|
|
46
47
|
* @param {Question<Promise<Answer>> | Question<Answer> | string} topic
|
|
47
48
|
*/
|
|
48
49
|
constructor(topic) {
|
|
49
|
-
super(
|
|
50
|
+
super();
|
|
50
51
|
this.topic = topic;
|
|
52
|
+
this.subject = (0, io_1.formatted) `a note of ${topic}`;
|
|
51
53
|
}
|
|
52
54
|
/**
|
|
53
55
|
* @desc
|
|
@@ -75,6 +77,20 @@ class Note extends Question_1.Question {
|
|
|
75
77
|
answeredBy(actor) {
|
|
76
78
|
return abilities_1.TakeNotes.as(actor).answerTo(this.topic);
|
|
77
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* @desc
|
|
82
|
+
* Changes the description of this question's subject.
|
|
83
|
+
*
|
|
84
|
+
* @param {string} subject
|
|
85
|
+
* @returns {Question<T>}
|
|
86
|
+
*/
|
|
87
|
+
describedAs(subject) {
|
|
88
|
+
this.subject = subject;
|
|
89
|
+
return this;
|
|
90
|
+
}
|
|
91
|
+
toString() {
|
|
92
|
+
return this.subject;
|
|
93
|
+
}
|
|
78
94
|
}
|
|
79
95
|
exports.Note = Note;
|
|
80
96
|
//# sourceMappingURL=Note.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Note.js","sourceRoot":"","sources":["../../../src/screenplay/questions/Note.ts"],"names":[],"mappings":";;;AAAA,4CAAyC;AAEzC,0CAAuC;AAEvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAa,IAAa,SAAQ,mBAAyB;
|
|
1
|
+
{"version":3,"file":"Note.js","sourceRoot":"","sources":["../../../src/screenplay/questions/Note.ts"],"names":[],"mappings":";;;AAAA,iCAAqC;AACrC,4CAAyC;AAEzC,0CAAuC;AAEvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAa,IAAa,SAAQ,mBAAyB;IAgBvD;;OAEG;IACH,YAA6B,KAA4D;QACrF,KAAK,EAAE,CAAC;QADiB,UAAK,GAAL,KAAK,CAAuD;QAErF,IAAI,CAAC,OAAO,GAAG,IAAA,cAAS,EAAC,aAAc,KAAM,EAAE,CAAC;IACpD,CAAC;IAlBD;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,CAAI,KAAkD;QAC3D,OAAO,IAAI,IAAI,CAAI,KAAK,CAAC,CAAC;IAC9B,CAAC;IAUD;;;;;;;;;;;OAWG;IACH,UAAU,CAAC,KAAuC;QAC9C,OAAO,qBAAS,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACpD,CAAC;IAED;;;;;;OAMG;IACH,WAAW,CAAC,OAAe;QACvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,QAAQ;QACJ,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;CACJ;AAvDD,oBAuDC"}
|
|
@@ -2,9 +2,6 @@ export * from './Check';
|
|
|
2
2
|
export * from './Expectation';
|
|
3
3
|
export * from './expectations';
|
|
4
4
|
export * from './List';
|
|
5
|
-
export * from './mappings';
|
|
6
5
|
export * from './MetaQuestion';
|
|
7
6
|
export * from './Note';
|
|
8
|
-
export { Property } from './Property';
|
|
9
7
|
export * from './q';
|
|
10
|
-
export * from './Transform';
|
|
@@ -10,16 +10,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.Property = void 0;
|
|
14
13
|
__exportStar(require("./Check"), exports);
|
|
15
14
|
__exportStar(require("./Expectation"), exports);
|
|
16
15
|
__exportStar(require("./expectations"), exports);
|
|
17
16
|
__exportStar(require("./List"), exports);
|
|
18
|
-
__exportStar(require("./mappings"), exports);
|
|
19
17
|
__exportStar(require("./MetaQuestion"), exports);
|
|
20
18
|
__exportStar(require("./Note"), exports);
|
|
21
|
-
var Property_1 = require("./Property");
|
|
22
|
-
Object.defineProperty(exports, "Property", { enumerable: true, get: function () { return Property_1.Property; } });
|
|
23
19
|
__exportStar(require("./q"), exports);
|
|
24
|
-
__exportStar(require("./Transform"), exports);
|
|
25
20
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/screenplay/questions/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/screenplay/questions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0CAAwB;AACxB,gDAA8B;AAC9B,iDAA+B;AAC/B,yCAAuB;AACvB,iDAA+B;AAC/B,yCAAuB;AACvB,sCAAoB"}
|
|
@@ -130,14 +130,15 @@ exports.ArrayListAdapter = ArrayListAdapter;
|
|
|
130
130
|
*/
|
|
131
131
|
class ArrayListFilter extends Question_1.Question {
|
|
132
132
|
constructor(collection, question, expectation) {
|
|
133
|
-
super(
|
|
134
|
-
(0, io_1.formatted) `${collection}`,
|
|
135
|
-
collection instanceof ArrayListFilter ? 'and' : 'where',
|
|
136
|
-
(0, io_1.formatted) `${question} does ${expectation}`
|
|
137
|
-
].join(' '));
|
|
133
|
+
super();
|
|
138
134
|
this.collection = collection;
|
|
139
135
|
this.question = question;
|
|
140
136
|
this.expectation = expectation;
|
|
137
|
+
this.subject = [
|
|
138
|
+
(0, io_1.formatted) `${collection}`,
|
|
139
|
+
collection instanceof ArrayListFilter ? 'and' : 'where',
|
|
140
|
+
(0, io_1.formatted) `${question} does ${expectation}`
|
|
141
|
+
].join(' ');
|
|
141
142
|
}
|
|
142
143
|
answeredBy(actor) {
|
|
143
144
|
return actor.answer(this.collection)
|
|
@@ -148,5 +149,19 @@ class ArrayListFilter extends Question_1.Question {
|
|
|
148
149
|
.then(results => results.filter(result => result.outcome instanceof expectations_1.ExpectationMet)
|
|
149
150
|
.map(result => result.item));
|
|
150
151
|
}
|
|
152
|
+
/**
|
|
153
|
+
* @desc
|
|
154
|
+
* Changes the description of this question's subject.
|
|
155
|
+
*
|
|
156
|
+
* @param {string} subject
|
|
157
|
+
* @returns {Question<T>}
|
|
158
|
+
*/
|
|
159
|
+
describedAs(subject) {
|
|
160
|
+
this.subject = subject;
|
|
161
|
+
return this;
|
|
162
|
+
}
|
|
163
|
+
toString() {
|
|
164
|
+
return this.subject;
|
|
165
|
+
}
|
|
151
166
|
}
|
|
152
167
|
//# sourceMappingURL=ArrayListAdapter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArrayListAdapter.js","sourceRoot":"","sources":["../../../../src/screenplay/questions/lists/ArrayListAdapter.ts"],"names":[],"mappings":";;;AAAA,2CAAuD;AAEvD,oCAAwC;AAGxC,6CAA0C;AAE1C,kDAAiD;AAIjD;;;;;GAKG;AACH,MAAa,gBAAgB;IAEzB;;OAEG;IACH,YAA6B,KAA8B;QAA9B,UAAK,GAAL,KAAK,CAAyB;IAC3D,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,KAAuC;QACzC,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;aACrB,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACrC,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,KAAuC;QACzC,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,KAAuC;QACzC,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;aACrB,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;IACjD,CAAC;IAED;;;;;;;;;;;OAWG;IACH,GAAG,CAAC,KAAuC,EAAE,KAAa;QACtD,OAAO,IAAI,CA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E;YACpD,CAAC,CAAC,gBAAgB,CAAC;QAEvB,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;YACpB,MAAM,IAAI,KAAK,CAAC,GAAI,WAAY,WAAW,CAAC,CAAC;SAChD;QAED,IAAI,KAAK,IAAI,KAAK,EAAE;YAChB,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC;SACvB;QAED,MAAM,IAAI,KAAK,CAAC,GAAI,WAAY,yBAA0B,KAAM,EAAE,CAAC,CAAC;IACxE,CAAC;CACJ;AAnID,4CAmIC;AAED;;GAEG;AACH,MAAM,eACF,SAAQ,mBAA8B;
|
|
1
|
+
{"version":3,"file":"ArrayListAdapter.js","sourceRoot":"","sources":["../../../../src/screenplay/questions/lists/ArrayListAdapter.ts"],"names":[],"mappings":";;;AAAA,2CAAuD;AAEvD,oCAAwC;AAGxC,6CAA0C;AAE1C,kDAAiD;AAIjD;;;;;GAKG;AACH,MAAa,gBAAgB;IAEzB;;OAEG;IACH,YAA6B,KAA8B;QAA9B,UAAK,GAAL,KAAK,CAAyB;IAC3D,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,KAAuC;QACzC,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;aACrB,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACrC,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,KAAuC;QACzC,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,KAAuC;QACzC,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;aACrB,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;IACjD,CAAC;IAED;;;;;;;;;;;OAWG;IACH,GAAG,CAAC,KAAuC,EAAE,KAAa;QACtD,OAAO,IAA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C,KAAK,CAAC,CAAC;aACpD,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC;aAC1D,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,CAC5C,CAAC,CACL;aACA,IAAI,CAAC,OAAO,CAAC,EAAE,CACZ,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,OAAO,YAAY,6BAAc,CAAC;aAC7D,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAClC,CAAC;IACV,CAAC;IAED;;;;;;OAMG;IACH,WAAW,CAAC,OAAe;QACvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,QAAQ;QACJ,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;CACJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serenity-js/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-rc.0",
|
|
4
4
|
"description": "Serenity/JS Screenplay, reporting engine and core interfaces.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Jan Molak",
|
|
@@ -47,17 +47,17 @@
|
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@documentation/esdoc-template": "2.0.0",
|
|
50
|
-
"@types/chai": "^4.
|
|
50
|
+
"@types/chai": "^4.3.0",
|
|
51
51
|
"@types/cuid": "^1.3.1",
|
|
52
52
|
"@types/diff": "^5.0.1",
|
|
53
53
|
"@types/filenamify": "^2.0.2",
|
|
54
54
|
"@types/mocha": "^9.0.0",
|
|
55
|
-
"@types/semver": "^7.3.
|
|
55
|
+
"@types/semver": "^7.3.9",
|
|
56
56
|
"assertion-error-formatter": "^3.0.0",
|
|
57
|
-
"memfs": "^3.
|
|
58
|
-
"mocha": "^9.1.
|
|
59
|
-
"ts-node": "^10.
|
|
60
|
-
"typescript": "^4.
|
|
57
|
+
"memfs": "^3.4.0",
|
|
58
|
+
"mocha": "^9.1.3",
|
|
59
|
+
"ts-node": "^10.4.0",
|
|
60
|
+
"typescript": "^4.5.2"
|
|
61
61
|
},
|
|
62
62
|
"repository": {
|
|
63
63
|
"type": "git",
|
|
@@ -67,8 +67,8 @@
|
|
|
67
67
|
"url": "https://github.com/serenity-js/serenity-js/issues"
|
|
68
68
|
},
|
|
69
69
|
"engines": {
|
|
70
|
-
"node": "^
|
|
71
|
-
"npm": "^6 || ^7"
|
|
70
|
+
"node": "^14 || ^16",
|
|
71
|
+
"npm": "^6 || ^7 || ^8"
|
|
72
72
|
},
|
|
73
73
|
"nyc": {
|
|
74
74
|
"include": [
|
|
@@ -92,5 +92,5 @@
|
|
|
92
92
|
"cache": true,
|
|
93
93
|
"all": true
|
|
94
94
|
},
|
|
95
|
-
"gitHead": "
|
|
95
|
+
"gitHead": "a63381d088cc068bc3edcbd1eb59a7e609cb6a8c"
|
|
96
96
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './errors';
|
|
2
2
|
export * from './instance';
|
|
3
|
-
export {
|
|
3
|
+
export { format } from './io';
|
|
4
|
+
export { Duration, Timestamp } from './model';
|
|
4
5
|
export * from './screenplay';
|
|
5
6
|
export * from './Serenity';
|
|
6
7
|
export { SerenityConfig } from './SerenityConfig';
|
|
@@ -39,10 +39,14 @@ export class ErrorSerialiser {
|
|
|
39
39
|
];
|
|
40
40
|
|
|
41
41
|
static serialise(error: Error): string {
|
|
42
|
+
const name = error && error.constructor && error.constructor.name
|
|
43
|
+
? error.constructor.name
|
|
44
|
+
: error.name;
|
|
45
|
+
|
|
42
46
|
const serialisedError = Object.getOwnPropertyNames(error).reduce((serialised, key) => {
|
|
43
47
|
serialised[key] = error[key]
|
|
44
48
|
return serialised;
|
|
45
|
-
}, { name
|
|
49
|
+
}, { name }) as SerialisedError;
|
|
46
50
|
|
|
47
51
|
return stringify(serialisedError);
|
|
48
52
|
}
|
package/src/io/format.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Answerable } from '../screenplay';
|
|
2
|
+
import { inspected } from './inspected';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @desc
|
|
6
|
+
* A factory function returning a tag function that produces a human-readable description of a template containing one or more {@link Answerable}s.
|
|
7
|
+
*
|
|
8
|
+
* @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#Tagged_template_literals
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* import { format, Question } from '@serenity-js/core';
|
|
12
|
+
*
|
|
13
|
+
* const someQuestion = () =>
|
|
14
|
+
* Question.about('some question', actor => 'some value');
|
|
15
|
+
*
|
|
16
|
+
* format({ markQuestions: true }) `actor answers ${ question() }`;
|
|
17
|
+
* // returns: actor answers <<some question>>
|
|
18
|
+
*
|
|
19
|
+
* format({ markQuestions: false }) `actor answers ${ question() }`;
|
|
20
|
+
* // returns: actor answers <<some question>>
|
|
21
|
+
*
|
|
22
|
+
* @example <caption>Aliasing</caption>
|
|
23
|
+
* import { format, Question } from '@serenity-js/core';
|
|
24
|
+
*
|
|
25
|
+
* const f = format({ markQuestions: true });
|
|
26
|
+
*
|
|
27
|
+
* const someQuestion = () =>
|
|
28
|
+
* Question.about('some question', actor => 'some value');
|
|
29
|
+
*
|
|
30
|
+
* f `actor answers ${ question() }`;
|
|
31
|
+
* // produces: actor answers <<some question>>
|
|
32
|
+
*
|
|
33
|
+
* @param {object} config
|
|
34
|
+
* - `markQuestions`: boolean - if set to true, descriptions of questions passed in as arguments will be surrounded with double angled brackets, i.e. `<<description>>`
|
|
35
|
+
* @returns {function(templates: TemplateStringsArray, placeholders: ...Array<Answerable<any>>): string}
|
|
36
|
+
*/
|
|
37
|
+
export function format(config: { markQuestions: boolean }): (templates: TemplateStringsArray, ...placeholders: Array<Answerable<any>>) => string {
|
|
38
|
+
return (templates: TemplateStringsArray, ...placeholders: Array<Answerable<any>>): string => {
|
|
39
|
+
return templates
|
|
40
|
+
.map((template, i) => i < placeholders.length
|
|
41
|
+
? [ template, inspected(placeholders[i], { inline: true, markQuestions: config.markQuestions }) ]
|
|
42
|
+
: [ template ])
|
|
43
|
+
.reduce((acc, tuple) => acc.concat(tuple))
|
|
44
|
+
.join('');
|
|
45
|
+
}
|
|
46
|
+
}
|
package/src/io/formatted.ts
CHANGED
|
@@ -1,28 +1,20 @@
|
|
|
1
|
-
import { Answerable } from '../screenplay
|
|
2
|
-
import {
|
|
1
|
+
import { Answerable } from '../screenplay';
|
|
2
|
+
import { format } from './format';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @desc
|
|
6
6
|
* A tag function returning a human-readable description of a template containing one or more {@link Answerable}s.
|
|
7
|
+
* This function is deprecated, please use {@link format} instead.
|
|
7
8
|
*
|
|
8
9
|
* @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#Tagged_template_literals
|
|
9
10
|
*
|
|
11
|
+
*
|
|
12
|
+
* @deprecated
|
|
13
|
+
*
|
|
10
14
|
* @param {TemplateStringsArray} templates
|
|
11
15
|
* @param {Array<Answerable<any>>} placeholders
|
|
12
16
|
* @returns {string}
|
|
13
17
|
*/
|
|
14
18
|
export function formatted(templates: TemplateStringsArray, ...placeholders: Array<Answerable<any>>): string {
|
|
15
|
-
return templates
|
|
16
|
-
.map((template, i) => i < placeholders.length
|
|
17
|
-
? [ template, compacted(inspected(placeholders[i])) ]
|
|
18
|
-
: [ template ])
|
|
19
|
-
.reduce((acc, tuple) => acc.concat(tuple))
|
|
20
|
-
.join('');
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/** @private */
|
|
24
|
-
function compacted(multiline: string) {
|
|
25
|
-
return multiline
|
|
26
|
-
.replace(/\r?\n/g, ' ')
|
|
27
|
-
.replace(/\s+/g, ' ');
|
|
19
|
+
return format({ markQuestions: false })(templates, ...placeholders);
|
|
28
20
|
}
|
package/src/io/index.ts
CHANGED
package/src/io/inspected.ts
CHANGED
|
@@ -3,6 +3,11 @@ import { inspect } from 'util';
|
|
|
3
3
|
import { Answerable } from '../screenplay/Answerable';
|
|
4
4
|
import { Question } from '../screenplay/Question';
|
|
5
5
|
|
|
6
|
+
interface InspectedConfig {
|
|
7
|
+
inline: boolean;
|
|
8
|
+
markQuestions?: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
6
11
|
/**
|
|
7
12
|
* @desc
|
|
8
13
|
* Provides a human-readable description of the {@link Answerable<T>}.
|
|
@@ -10,27 +15,29 @@ import { Question } from '../screenplay/Question';
|
|
|
10
15
|
*
|
|
11
16
|
* @public
|
|
12
17
|
* @param {Answerable<any>} value
|
|
18
|
+
* @param config
|
|
19
|
+
* - inline - Return a single-line string instead of the default potentially multi-line description
|
|
20
|
+
* - markQuestions - Surround the description of async values, such as Promises and Questions with <<value>>
|
|
13
21
|
* @return {string}
|
|
14
22
|
*/
|
|
15
|
-
export function inspected(value: Answerable<any
|
|
23
|
+
export function inspected(value: Answerable<any>, config?: InspectedConfig): string {
|
|
24
|
+
|
|
25
|
+
const { inline, markQuestions } = { inline: false, markQuestions: false, ...config };
|
|
26
|
+
|
|
16
27
|
if (! isDefined(value)) {
|
|
17
28
|
return inspect(value);
|
|
18
29
|
}
|
|
19
30
|
|
|
20
31
|
if (Array.isArray(value)) {
|
|
21
|
-
return
|
|
22
|
-
'[',
|
|
23
|
-
value.map(item => ` ${ inspected(item) }`).join(',\n'),
|
|
24
|
-
']',
|
|
25
|
-
].join('\n');
|
|
32
|
+
return stringifiedArray(value, inline);
|
|
26
33
|
}
|
|
27
34
|
|
|
28
35
|
if (isAPromise(value)) {
|
|
29
|
-
return
|
|
36
|
+
return markAs('Promise', true);
|
|
30
37
|
}
|
|
31
38
|
|
|
32
39
|
if (Question.isAQuestion(value)) {
|
|
33
|
-
return value.toString();
|
|
40
|
+
return markAs(value.toString(), markQuestions);
|
|
34
41
|
}
|
|
35
42
|
|
|
36
43
|
if (isADate(value)) {
|
|
@@ -45,15 +52,49 @@ export function inspected(value: Answerable<any>): string {
|
|
|
45
52
|
return value.inspect();
|
|
46
53
|
}
|
|
47
54
|
|
|
48
|
-
if (
|
|
49
|
-
return
|
|
55
|
+
if (isAFunction(value)) {
|
|
56
|
+
return hasName(value)
|
|
57
|
+
? value.name
|
|
58
|
+
: markAs(`Function`, true);
|
|
50
59
|
}
|
|
51
60
|
|
|
52
61
|
if (! hasCustomInspectionFunction(value) && isPlainObject(value) && isSerialisableAsJSON(value)) {
|
|
53
|
-
return
|
|
62
|
+
return stringifiedToJson(value, inline);
|
|
54
63
|
}
|
|
55
64
|
|
|
56
|
-
return inspect(value, { breakLength: Number.POSITIVE_INFINITY, compact:
|
|
65
|
+
return inspect(value, { breakLength: Number.POSITIVE_INFINITY, compact: ! inline, sorted: false });
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function stringifiedToJson(value: any, inline: boolean): string {
|
|
69
|
+
const indentation = inline ? 0 : 4;
|
|
70
|
+
|
|
71
|
+
return JSON.stringify(value, undefined, indentation);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function stringifiedArray(value: any[], inline: boolean): string {
|
|
75
|
+
const indentation = inline ? '' : ' ';
|
|
76
|
+
const separator = inline ? ' ' : '\n';
|
|
77
|
+
|
|
78
|
+
const inspectedItem = (item: unknown, index: number) =>
|
|
79
|
+
[
|
|
80
|
+
indentation,
|
|
81
|
+
inspected(item, { inline, markQuestions: true }),
|
|
82
|
+
index < value.length - 1 ? ',' : ''
|
|
83
|
+
].join('')
|
|
84
|
+
|
|
85
|
+
return [
|
|
86
|
+
'[',
|
|
87
|
+
...value.map(inspectedItem),
|
|
88
|
+
']',
|
|
89
|
+
].join(separator);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function markAs(value: string, markValue: boolean): string {
|
|
93
|
+
const [left, right] = markValue && ! value.startsWith('<<')
|
|
94
|
+
? [ '<<', '>>' ]
|
|
95
|
+
: ['', ''];
|
|
96
|
+
|
|
97
|
+
return [ left, value, right ].join('');
|
|
57
98
|
}
|
|
58
99
|
|
|
59
100
|
/**
|
|
@@ -121,8 +162,19 @@ function isAPromise<T>(v: Answerable<T>): v is Promise<T> {
|
|
|
121
162
|
* @private
|
|
122
163
|
* @param {Answerable<any>} v
|
|
123
164
|
*/
|
|
124
|
-
function
|
|
125
|
-
return Object.prototype.toString.call(v) === '[object Function]'
|
|
165
|
+
function isAFunction(v: any): v is Function { // eslint-disable-line @typescript-eslint/ban-types
|
|
166
|
+
return Object.prototype.toString.call(v) === '[object Function]';
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* @desc
|
|
171
|
+
* Checks if the value is has a property called 'name' with a non-empty value.
|
|
172
|
+
*
|
|
173
|
+
* @private
|
|
174
|
+
* @param {Answerable<any>} v
|
|
175
|
+
*/
|
|
176
|
+
function hasName(v: any): v is { name: string } {
|
|
177
|
+
return typeof (v as any).name === 'string' && (v as any).name !== '';
|
|
126
178
|
}
|
|
127
179
|
|
|
128
180
|
/**
|
package/src/model/Timestamp.ts
CHANGED
|
@@ -8,7 +8,11 @@ export class Timestamp extends TinyType {
|
|
|
8
8
|
return new Timestamp(new Date(ensure(Timestamp.name, v, isSerialisedISO8601Date())));
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
static
|
|
11
|
+
static fromTimestampInSeconds(v: number): Timestamp {
|
|
12
|
+
return Timestamp.fromTimestampInMilliseconds(v * 1000);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
static fromTimestampInMilliseconds(v: number): Timestamp {
|
|
12
16
|
return new Timestamp(moment(v).toDate());
|
|
13
17
|
}
|
|
14
18
|
|
|
@@ -29,10 +33,14 @@ export class Timestamp extends TinyType {
|
|
|
29
33
|
return new Timestamp(moment(this.value).subtract(duration.inMilliseconds(), 'ms').toDate());
|
|
30
34
|
}
|
|
31
35
|
|
|
32
|
-
|
|
36
|
+
toMilliseconds(): number {
|
|
33
37
|
return moment(this.value).valueOf();
|
|
34
38
|
}
|
|
35
39
|
|
|
40
|
+
toSeconds(): number {
|
|
41
|
+
return moment(this.value).unix();
|
|
42
|
+
}
|
|
43
|
+
|
|
36
44
|
toJSON(): string {
|
|
37
45
|
return this.value.toJSON();
|
|
38
46
|
}
|