@serenity-js/core 2.33.1 → 3.0.0-rc.11
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 +476 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +6 -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/ErrorStackParser.d.ts +2 -2
- package/lib/io/ErrorStackParser.js.map +1 -1
- package/lib/io/asyncMap.d.ts +8 -0
- package/lib/io/asyncMap.js +18 -0
- package/lib/io/asyncMap.js.map +1 -0
- package/lib/io/format.d.ts +39 -0
- package/lib/io/format.js +51 -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 +2 -1
- package/lib/io/index.js +2 -1
- package/lib/io/index.js.map +1 -1
- package/lib/io/inspected.d.ts +9 -1
- package/lib/io/inspected.js +52 -15
- 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/Optional.d.ts +29 -0
- package/lib/{io/collections/reducible.js → screenplay/Optional.js} +1 -1
- package/lib/screenplay/Optional.js.map +1 -0
- package/lib/screenplay/Question.d.ts +41 -82
- package/lib/screenplay/Question.js +132 -100
- 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/interactions/index.d.ts +0 -1
- package/lib/screenplay/interactions/index.js +0 -1
- package/lib/screenplay/interactions/index.js.map +1 -1
- package/lib/screenplay/questions/Check.d.ts +3 -3
- package/lib/screenplay/questions/Check.js +5 -7
- package/lib/screenplay/questions/Check.js.map +1 -1
- package/lib/screenplay/questions/Expectation.d.ts +15 -10
- package/lib/screenplay/questions/Expectation.js +28 -37
- package/lib/screenplay/questions/Expectation.js.map +1 -1
- package/lib/screenplay/questions/List.d.ts +22 -192
- package/lib/screenplay/questions/List.js +160 -208
- 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/stage/index.d.ts +0 -2
- package/lib/stage/index.js +0 -2
- package/lib/stage/index.js.map +1 -1
- package/package.json +7 -6
- package/src/index.ts +2 -1
- package/src/io/ErrorSerialiser.ts +5 -1
- package/src/io/ErrorStackParser.ts +2 -1
- package/src/io/asyncMap.ts +18 -0
- package/src/io/format.ts +49 -0
- package/src/io/formatted.ts +7 -15
- package/src/io/index.ts +2 -1
- package/src/io/inspected.ts +68 -15
- package/src/model/Timestamp.ts +10 -2
- package/src/screenplay/Optional.ts +30 -0
- package/src/screenplay/Question.ts +206 -124
- package/src/screenplay/actor/Actor.ts +2 -2
- package/src/screenplay/index.ts +1 -1
- package/src/screenplay/interactions/index.ts +0 -1
- package/src/screenplay/questions/Check.ts +10 -15
- package/src/screenplay/questions/Expectation.ts +47 -55
- package/src/screenplay/questions/List.ts +224 -233
- package/src/screenplay/questions/Note.ts +21 -1
- package/src/screenplay/questions/index.ts +0 -3
- package/src/stage/index.ts +0 -2
- package/lib/io/collections/index.d.ts +0 -2
- package/lib/io/collections/index.js +0 -15
- package/lib/io/collections/index.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/io/collections/reducible.d.ts +0 -16
- package/lib/io/collections/reducible.js.map +0 -1
- package/lib/screenplay/interactions/See.d.ts +0 -31
- package/lib/screenplay/interactions/See.js +0 -43
- package/lib/screenplay/interactions/See.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/lists/ArrayListAdapter.d.ts +0 -88
- package/lib/screenplay/questions/lists/ArrayListAdapter.js +0 -152
- package/lib/screenplay/questions/lists/ArrayListAdapter.js.map +0 -1
- package/lib/screenplay/questions/lists/ListAdapter.d.ts +0 -20
- package/lib/screenplay/questions/lists/ListAdapter.js +0 -3
- package/lib/screenplay/questions/lists/ListAdapter.js.map +0 -1
- package/lib/screenplay/questions/lists/index.d.ts +0 -2
- package/lib/screenplay/questions/lists/index.js +0 -15
- package/lib/screenplay/questions/lists/index.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 +0 -3
- 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 +0 -14
- package/lib/screenplay/tasks/index.js.map +0 -1
- package/lib/stage/DressingRoom.d.ts +0 -37
- package/lib/stage/DressingRoom.js +0 -53
- package/lib/stage/DressingRoom.js.map +0 -1
- package/lib/stage/WithStage.d.ts +0 -51
- package/lib/stage/WithStage.js +0 -3
- package/lib/stage/WithStage.js.map +0 -1
- package/src/io/collections/index.ts +0 -2
- package/src/io/collections/mappable.ts +0 -60
- package/src/io/collections/reducible.ts +0 -16
- package/src/screenplay/interactions/See.ts +0 -45
- package/src/screenplay/questions/Property.ts +0 -98
- package/src/screenplay/questions/Transform.ts +0 -51
- package/src/screenplay/questions/lists/ArrayListAdapter.ts +0 -186
- package/src/screenplay/questions/lists/ListAdapter.ts +0 -33
- package/src/screenplay/questions/lists/index.ts +0 -2
- 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
- package/src/stage/DressingRoom.ts +0 -53
- package/src/stage/WithStage.ts +0 -52
|
@@ -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"}
|
package/lib/stage/index.d.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
export * from './Cast';
|
|
2
2
|
export * from './Clock';
|
|
3
3
|
export * from './crew';
|
|
4
|
-
export * from './DressingRoom';
|
|
5
4
|
export * from './ListensToDomainEvents';
|
|
6
5
|
export * from './Stage';
|
|
7
6
|
export * from './StageCrewMember';
|
|
8
7
|
export * from './StageCrewMemberBuilder';
|
|
9
8
|
export * from './StageCrewMemberBuilderDependencies';
|
|
10
9
|
export * from './StageManager';
|
|
11
|
-
export * from './WithStage';
|
package/lib/stage/index.js
CHANGED
|
@@ -13,12 +13,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
13
13
|
__exportStar(require("./Cast"), exports);
|
|
14
14
|
__exportStar(require("./Clock"), exports);
|
|
15
15
|
__exportStar(require("./crew"), exports);
|
|
16
|
-
__exportStar(require("./DressingRoom"), exports);
|
|
17
16
|
__exportStar(require("./ListensToDomainEvents"), exports);
|
|
18
17
|
__exportStar(require("./Stage"), exports);
|
|
19
18
|
__exportStar(require("./StageCrewMember"), exports);
|
|
20
19
|
__exportStar(require("./StageCrewMemberBuilder"), exports);
|
|
21
20
|
__exportStar(require("./StageCrewMemberBuilderDependencies"), exports);
|
|
22
21
|
__exportStar(require("./StageManager"), exports);
|
|
23
|
-
__exportStar(require("./WithStage"), exports);
|
|
24
22
|
//# sourceMappingURL=index.js.map
|
package/lib/stage/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/stage/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAuB;AACvB,0CAAwB;AACxB,yCAAuB;AACvB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/stage/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAuB;AACvB,0CAAwB;AACxB,yCAAuB;AACvB,0DAAwC;AACxC,0CAAwB;AACxB,oDAAkC;AAClC,2DAAyC;AACzC,uEAAqD;AACrD,iDAA+B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serenity-js/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-rc.11",
|
|
4
4
|
"description": "Serenity/JS Screenplay, reporting engine and core interfaces.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Jan Molak",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
],
|
|
28
28
|
"scripts": {
|
|
29
29
|
"clean": "rimraf .nyc_output lib target",
|
|
30
|
-
"lint": "eslint --ext ts --config ../../.eslintrc.
|
|
30
|
+
"lint": "eslint --ext ts --config ../../.eslintrc.yml .",
|
|
31
31
|
"lint:fix": "npm run lint -- --fix",
|
|
32
32
|
"test": "nyc --report-dir ../../target/coverage/core mocha --config ../../.mocharc.yml 'spec/**/*.spec.*'",
|
|
33
33
|
"compile": "tsc --project tsconfig.json",
|
|
@@ -36,17 +36,18 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"cuid": "^2.1.8",
|
|
38
38
|
"diff": "^5.0.0",
|
|
39
|
-
"error-stack-parser": "^2.0.
|
|
39
|
+
"error-stack-parser": "^2.0.7",
|
|
40
40
|
"fast-glob": "^3.2.11",
|
|
41
41
|
"filenamify": "^4.3.0",
|
|
42
42
|
"graceful-fs": "^4.2.9",
|
|
43
43
|
"moment": "^2.29.1",
|
|
44
44
|
"semver": "^7.3.5",
|
|
45
|
+
"stackframe": "^1.2.0",
|
|
45
46
|
"tiny-types": "^1.17.0",
|
|
46
47
|
"upath": "^2.0.1"
|
|
47
48
|
},
|
|
48
49
|
"devDependencies": {
|
|
49
|
-
"@documentation/esdoc-template": "
|
|
50
|
+
"@documentation/esdoc-template": "3.0.0",
|
|
50
51
|
"@types/chai": "^4.3.0",
|
|
51
52
|
"@types/cuid": "^1.3.1",
|
|
52
53
|
"@types/diff": "^5.0.2",
|
|
@@ -67,7 +68,7 @@
|
|
|
67
68
|
"url": "https://github.com/serenity-js/serenity-js/issues"
|
|
68
69
|
},
|
|
69
70
|
"engines": {
|
|
70
|
-
"node": "^
|
|
71
|
+
"node": "^14 || ^16",
|
|
71
72
|
"npm": "^6 || ^7 || ^8"
|
|
72
73
|
},
|
|
73
74
|
"nyc": {
|
|
@@ -92,5 +93,5 @@
|
|
|
92
93
|
"cache": true,
|
|
93
94
|
"all": true
|
|
94
95
|
},
|
|
95
|
-
"gitHead": "
|
|
96
|
+
"gitHead": "0a232ce7ff21df56a9cc9e64859af5b0bce33b32"
|
|
96
97
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './errors';
|
|
2
2
|
export * from './instance';
|
|
3
|
-
export {
|
|
3
|
+
export { d, f, 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
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as parser from 'error-stack-parser';
|
|
2
|
+
import StackFrame = require('stackframe');
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* @desc
|
|
@@ -9,7 +10,7 @@ import * as parser from 'error-stack-parser';
|
|
|
9
10
|
* @package
|
|
10
11
|
*/
|
|
11
12
|
export class ErrorStackParser {
|
|
12
|
-
parse(error: Error):
|
|
13
|
+
parse(error: Error): StackFrame[] {
|
|
13
14
|
return parser.parse(error);
|
|
14
15
|
}
|
|
15
16
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @desc
|
|
3
|
+
* Maps an Array<Item_Type> to an Array<Result_Type>, one element at a time.
|
|
4
|
+
*
|
|
5
|
+
* @param {Array<Item_Type>} items
|
|
6
|
+
* @param {function(item: Item_Type): Promise<Result_Type>} mappingFunction
|
|
7
|
+
*/
|
|
8
|
+
export function asyncMap<Item_Type, Result_Type>(items: Item_Type[], mappingFunction: (item: Item_Type) => Promise<Result_Type> | Result_Type): Promise<Result_Type[]> {
|
|
9
|
+
return items.reduce(
|
|
10
|
+
(previous, item) =>
|
|
11
|
+
previous.then(async (acc) => {
|
|
12
|
+
const result = await mappingFunction(item);
|
|
13
|
+
|
|
14
|
+
return acc.concat(result);
|
|
15
|
+
})
|
|
16
|
+
, Promise.resolve([])
|
|
17
|
+
);
|
|
18
|
+
}
|
package/src/io/format.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
}
|
|
47
|
+
|
|
48
|
+
export const f = format({ markQuestions: true });
|
|
49
|
+
export const d = format({ markQuestions: false });
|
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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * from './AssertionReportDiffer';
|
|
2
|
-
export * from './
|
|
2
|
+
export * from './asyncMap';
|
|
3
3
|
export * from './commaSeparated';
|
|
4
4
|
export * from './Config';
|
|
5
5
|
export * from './ErrorSerialiser';
|
|
@@ -7,6 +7,7 @@ export * from './ErrorStackParser';
|
|
|
7
7
|
export * from './FileFinder';
|
|
8
8
|
export * from './FileSystem';
|
|
9
9
|
export * from './FileSystemLocation';
|
|
10
|
+
export * from './format';
|
|
10
11
|
export * from './formatted';
|
|
11
12
|
export * from './json';
|
|
12
13
|
export * from './ModuleLoader';
|
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 ? 3 : false, 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
|
/**
|
|
@@ -111,7 +152,8 @@ function isADate(v: Answerable<any>): v is Date {
|
|
|
111
152
|
* @param {Answerable<any>} v
|
|
112
153
|
*/
|
|
113
154
|
function isAPromise<T>(v: Answerable<T>): v is Promise<T> {
|
|
114
|
-
return
|
|
155
|
+
return typeof v === 'object'
|
|
156
|
+
&& 'then' in v;
|
|
115
157
|
}
|
|
116
158
|
|
|
117
159
|
/**
|
|
@@ -121,8 +163,19 @@ function isAPromise<T>(v: Answerable<T>): v is Promise<T> {
|
|
|
121
163
|
* @private
|
|
122
164
|
* @param {Answerable<any>} v
|
|
123
165
|
*/
|
|
124
|
-
function
|
|
125
|
-
return Object.prototype.toString.call(v) === '[object Function]'
|
|
166
|
+
function isAFunction(v: any): v is Function { // eslint-disable-line @typescript-eslint/ban-types
|
|
167
|
+
return Object.prototype.toString.call(v) === '[object Function]';
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* @desc
|
|
172
|
+
* Checks if the value is has a property called 'name' with a non-empty value.
|
|
173
|
+
*
|
|
174
|
+
* @private
|
|
175
|
+
* @param {Answerable<any>} v
|
|
176
|
+
*/
|
|
177
|
+
function hasName(v: any): v is { name: string } {
|
|
178
|
+
return typeof (v as any).name === 'string' && (v as any).name !== '';
|
|
126
179
|
}
|
|
127
180
|
|
|
128
181
|
/**
|
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
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Answerable } from './Answerable';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @desc
|
|
5
|
+
* `Optional` is a container object, which holds a value that may or may not be "present",
|
|
6
|
+
*
|
|
7
|
+
* The meaning of being "present" depends on the context and typically means a value that:
|
|
8
|
+
* - is other than `null` or `undefined`
|
|
9
|
+
* - is retrievable, so retrieving it doesn't throw any errors
|
|
10
|
+
*
|
|
11
|
+
* Additionally, `Optional` can also have a context-specific meaning. For example, `Optional#isPresent()`:
|
|
12
|
+
* - in the context of a `PageElement` means that the element exists in the DOM.
|
|
13
|
+
* - in the context of a `ModalWindow` means that the modal window is open.
|
|
14
|
+
* - in the case of a REST API response, `LastResponse.body().books[0].author.name.isPresent()`
|
|
15
|
+
* will inform us if a given entry exists (so `books[0].author.name`),
|
|
16
|
+
* and if all the links of the property chain leading to the entry of interest exist too
|
|
17
|
+
* (so `books` is present, and so is `books[0]`, `books[0].author`, `books[0].author.name`).
|
|
18
|
+
*
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
export interface Optional {
|
|
22
|
+
/**
|
|
23
|
+
* @desc
|
|
24
|
+
* Returns an {@link Answerable} that resolves to `true` when the optional value
|
|
25
|
+
* is present, `false` otherwise.
|
|
26
|
+
*
|
|
27
|
+
* @returns {Answerable<boolean>}
|
|
28
|
+
*/
|
|
29
|
+
isPresent(): Answerable<boolean>;
|
|
30
|
+
}
|