@serenity-js/assertions 3.0.0-rc.26 → 3.0.0-rc.28

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,6 +3,31 @@
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.28](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.27...v3.0.0-rc.28) (2022-09-30)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **core:** activity is now able to detect invocation location on Node 14 ([41f4776](https://github.com/serenity-js/serenity-js/commit/41f4776736620bc32d474d9b66f69c742f8eca96)), closes [#1240](https://github.com/serenity-js/serenity-js/issues/1240)
12
+
13
+
14
+ ### Features
15
+
16
+ * **assertions:** new assertion about a property of an object ([9cc03d5](https://github.com/serenity-js/serenity-js/commit/9cc03d5c80c03d1969238e63018c6d5320c6a539))
17
+ * **playwright-test:** improved Playwright Test reports ([6c6b537](https://github.com/serenity-js/serenity-js/commit/6c6b5379dfc324a4fb75d758daa7782109f1c5ab)), closes [#1240](https://github.com/serenity-js/serenity-js/issues/1240)
18
+
19
+
20
+
21
+
22
+
23
+ # [3.0.0-rc.27](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.26...v3.0.0-rc.27) (2022-08-26)
24
+
25
+ **Note:** Version bump only for package @serenity-js/assertions
26
+
27
+
28
+
29
+
30
+
6
31
  # [3.0.0-rc.26](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.25...v3.0.0-rc.26) (2022-08-15)
7
32
 
8
33
  **Note:** Version bump only for package @serenity-js/assertions
package/lib/Ensure.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Answerable, AnswersQuestions, AssertionError, CollectsArtifacts, Expectation, ExpectationOutcome, Interaction, RuntimeError, UsesAbilities } from '@serenity-js/core';
2
+ import { FileSystemLocation } from '@serenity-js/core/lib/io';
2
3
  /**
3
4
  * The {@apilink Interaction|interaction} to `Ensure`
4
5
  * verifies if the resolved value of the provided {@apilink Answerable}
@@ -62,16 +63,13 @@ export declare class Ensure<Actual> extends Interaction {
62
63
  /**
63
64
  * @param actual
64
65
  * @param expectation
66
+ * @param location
65
67
  */
66
- constructor(actual: Answerable<Actual>, expectation: Expectation<Actual>);
68
+ protected constructor(actual: Answerable<Actual>, expectation: Expectation<Actual>, location: FileSystemLocation);
67
69
  /**
68
70
  * @inheritDoc
69
71
  */
70
72
  performAs(actor: UsesAbilities & AnswersQuestions & CollectsArtifacts): Promise<void>;
71
- /**
72
- * @inheritDoc
73
- */
74
- toString(): string;
75
73
  /**
76
74
  * Overrides the default {@apilink AssertionError} thrown when
77
75
  * the actual value does not meet the expectation.
@@ -1 +1 @@
1
- {"version":3,"file":"Ensure.d.ts","sourceRoot":"","sources":["../src/Ensure.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,UAAU,EACV,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EAEjB,WAAW,EAGX,kBAAkB,EAElB,WAAW,EAEX,YAAY,EACZ,aAAa,EAChB,MAAM,mBAAmB,CAAC;AAK3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,qBAAa,MAAM,CAAC,MAAM,CAAE,SAAQ,WAAW;IAoBvC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC;IAC7C,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC;IAnBvD;;;;;;;;OAQG;IACH,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,CAAC,WAAW,CAAC,EAAE,WAAW,EAAE,WAAW,CAAC,WAAW,CAAC,GAAG,MAAM,CAAC,WAAW,CAAC;IAIrH;;;OAGG;gBAEoB,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,EAC1B,WAAW,EAAE,WAAW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,WAAW,CAAC,WAAW,CAAC,GAAG,MAAM,CAAC,WAAW,CAAC;IAIrH;;;;OAIG;IACH,SAAS,aACc,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,EAC1B,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,EACnD,QAAQ,EAAE,kBAAkB;IAKhC;;OAEG;IACG,SAAS,CAAC,KAAK,EAAE,aAAa,GAAG,gBAAgB,GAAG,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAe3F;;;;;;;;;OASG;IACH,iBAAiB,CAAC,kBAAkB,EAAE,KAAK,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,KAAK,YAAY,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,WAAW;IAI1H;;OAEG;IACH,SAAS,CAAC,eAAe,CAAC,OAAO,EAAE,kBAAkB,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,YAAY;IAIjF;;;;OAIG;IACH,SAAS,CAAC,gBAAgB,CAAC,OAAO,EAAE,kBAAkB,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,cAAc;IAQpF,OAAO,CAAC,YAAY;CAMvB"}
package/lib/Ensure.js CHANGED
@@ -56,9 +56,10 @@ class Ensure extends core_1.Interaction {
56
56
  /**
57
57
  * @param actual
58
58
  * @param expectation
59
+ * @param location
59
60
  */
60
- constructor(actual, expectation) {
61
- super();
61
+ constructor(actual, expectation, location) {
62
+ super((0, core_1.d) `#actor ensures that ${actual} does ${expectation}`, location);
62
63
  this.actual = actual;
63
64
  this.expectation = expectation;
64
65
  }
@@ -72,7 +73,7 @@ class Ensure extends core_1.Interaction {
72
73
  * @returns {Ensure<Actual_Type>}
73
74
  */
74
75
  static that(actual, expectation) {
75
- return new Ensure(actual, expectation);
76
+ return new Ensure(actual, expectation, core_1.Activity.callerLocation(5));
76
77
  }
77
78
  /**
78
79
  * @inheritDoc
@@ -89,12 +90,6 @@ class Ensure extends core_1.Interaction {
89
90
  throw new core_1.LogicError((0, core_1.f) `Expectation#isMetFor(actual) should return an instance of an ExpectationOutcome, not ${o}`);
90
91
  });
91
92
  }
92
- /**
93
- * @inheritDoc
94
- */
95
- toString() {
96
- return (0, core_1.d) `#actor ensures that ${this.actual} does ${this.expectation}`;
97
- }
98
93
  /**
99
94
  * Overrides the default {@apilink AssertionError} thrown when
100
95
  * the actual value does not meet the expectation.
@@ -135,7 +130,7 @@ exports.Ensure = Ensure;
135
130
  */
136
131
  class EnsureOrFailWithCustomError extends Ensure {
137
132
  constructor(actual, expectation, typeOfRuntimeError, message) {
138
- super(actual, expectation);
133
+ super(actual, expectation, core_1.Activity.callerLocation(6));
139
134
  this.typeOfRuntimeError = typeOfRuntimeError;
140
135
  this.message = message;
141
136
  }
package/lib/Ensure.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Ensure.js","sourceRoot":"","sources":["../src/Ensure.ts"],"names":[],"mappings":";;;AAAA,4CAe2B;AAC3B,kEAA+D;AAC/D,uDAA8E;AAC9E,2CAAmC;AAEnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,MAAa,MAAe,SAAQ,kBAAW;IAe3C;;;OAGG;IACH,YACuB,MAA0B,EAC1B,WAAgC;QAEnD,KAAK,EAAE,CAAC;QAHW,WAAM,GAAN,MAAM,CAAoB;QAC1B,gBAAW,GAAX,WAAW,CAAqB;IAGvD,CAAC;IAtBD;;;;;;;;OAQG;IACH,MAAM,CAAC,IAAI,CAAc,MAA+B,EAAE,WAAqC;QAC3F,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAC3C,CAAC;IAaD;;OAEG;IACH,KAAK,CAAC,SAAS,CAAC,KAA2D;QACvE,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QAE3E,OAAO,IAAA,kBAAK,EAA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AAE,EAC3D,OAAO,CAAC,QAAQ,EAChB,OAAO,CAAC,MAAM,CACjB,CAAC;IACN,CAAC;IAEO,YAAY,CAAC,QAAa,EAAE,MAAc;QAC9C,OAAO,uBAAe,CAAC,QAAQ,CAAC;YAC5B,QAAQ,EAAE,IAAA,qBAAS,EAAC,QAAQ,CAAC;YAC7B,MAAM,EAAE,IAAA,qBAAS,EAAC,MAAM,CAAC;SAC5B,CAAC,CAAC;IACP,CAAC;CACJ;AAtFD,wBAsFC;AAED;;GAEG;AACH,MAAM,2BAAoC,SAAQ,MAAc;IAC5D,YACI,MAA0B,EAC1B,WAAgC,EACf,kBAAwE,EACxE,OAAgB;QAEjC,KAAK,CAAC,MAAM,EAAE,WAAW,EAAE,eAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;QAHtC,uBAAkB,GAAlB,kBAAkB,CAAsD;QACxE,YAAO,GAAP,OAAO,CAAS;IAGrC,CAAC;IAES,eAAe,CAAC,OAAwC;QAC9D,MAAM,cAAc,GAAG,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;QAEtD,OAAO,IAAI,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,OAAO,IAAI,cAAc,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IAC/F,CAAC;CACJ"}
@@ -16,5 +16,6 @@ export * from './isTrue';
16
16
  export * from './matches';
17
17
  export * from './not';
18
18
  export * from './or';
19
+ export * from './property';
19
20
  export * from './startsWith';
20
21
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/expectations/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,WAAW,CAAC;AAC1B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,OAAO,CAAC;AACtB,cAAc,MAAM,CAAC;AACrB,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/expectations/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,WAAW,CAAC;AAC1B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,OAAO,CAAC;AACtB,cAAc,MAAM,CAAC;AACrB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC"}
@@ -32,5 +32,6 @@ __exportStar(require("./isTrue"), exports);
32
32
  __exportStar(require("./matches"), exports);
33
33
  __exportStar(require("./not"), exports);
34
34
  __exportStar(require("./or"), exports);
35
+ __exportStar(require("./property"), exports);
35
36
  __exportStar(require("./startsWith"), exports);
36
37
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/expectations/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAsB;AACtB,4CAA0B;AAC1B,8DAA4C;AAC5C,8DAA4C;AAC5C,6CAA2B;AAC3B,2CAAyB;AACzB,6CAA2B;AAC3B,4CAA0B;AAC1B,6CAA2B;AAC3B,8CAA4B;AAC5B,4CAA0B;AAC1B,kDAAgC;AAChC,+CAA6B;AAC7B,8CAA4B;AAC5B,2CAAyB;AACzB,4CAA0B;AAC1B,wCAAsB;AACtB,uCAAqB;AACrB,+CAA6B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/expectations/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAsB;AACtB,4CAA0B;AAC1B,8DAA4C;AAC5C,8DAA4C;AAC5C,6CAA2B;AAC3B,2CAAyB;AACzB,6CAA2B;AAC3B,4CAA0B;AAC1B,6CAA2B;AAC3B,8CAA4B;AAC5B,4CAA0B;AAC1B,kDAAgC;AAChC,+CAA6B;AAC7B,8CAA4B;AAC5B,2CAAyB;AACzB,4CAA0B;AAC1B,wCAAsB;AACtB,uCAAqB;AACrB,6CAA2B;AAC3B,+CAA6B"}
@@ -0,0 +1,62 @@
1
+ import { Expectation } from '@serenity-js/core';
2
+ /**
3
+ * Creates an {@apilink Expectation|expectation} that is met when the value of
4
+ * the `actual[propertyName]` meets the `expectation`.
5
+ *
6
+ * ## Ensuring that an array has an item
7
+ *
8
+ * ```ts
9
+ * import { actorCalled } from '@serenity-js/core'
10
+ * import { Ensure, property } from '@serenity-js/assertions'
11
+ *
12
+ * const list = [ 'hello', 'world' ]
13
+ *
14
+ * await actorCalled('Ester').attemptsTo(
15
+ * Ensure.that(list, property(0, isPresent())),
16
+ * )
17
+ * ```
18
+ *
19
+ * ## Ensuring that the property meets an expectation
20
+ *
21
+ * ```ts
22
+ * import { actorCalled } from '@serenity-js/core'
23
+ * import { Ensure, property, equals } from '@serenity-js/assertions'
24
+ *
25
+ * const list = [ 'hello', 'world' ]
26
+ *
27
+ * await actorCalled('Ester').attemptsTo(
28
+ * Ensure.that(list, property('length', equals(2))),
29
+ * )
30
+ * ```
31
+ *
32
+ * ## Asserting on a list of objects
33
+ *
34
+ * ```ts
35
+ * import { actorCalled } from '@serenity-js/core'
36
+ * import { Ensure, property, equals } from '@serenity-js/assertions'
37
+ *
38
+ * const developers = [{
39
+ * name: 'Jan',
40
+ * id: '@jan-molak',
41
+ * }, {
42
+ * name: 'John',
43
+ * id: '@wakaleo',
44
+ * }]
45
+ *
46
+ * await actorCalled('Ester').attemptsTo(
47
+ * Ensure.that(
48
+ * developers,
49
+ * containItemsWhereEachItem(
50
+ * property('id', startsWith('@'))
51
+ * ),
52
+ * ),
53
+ * )
54
+ * ```
55
+ *
56
+ * @param propertyName
57
+ * @param expectation
58
+ *
59
+ * @group Expectations
60
+ */
61
+ export declare function property<Actual extends object, PropertyName extends keyof Actual>(propertyName: PropertyName, expectation: Expectation<Actual[PropertyName]>): Expectation<Actual>;
62
+ //# sourceMappingURL=property.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"property.d.ts","sourceRoot":"","sources":["../../src/expectations/property.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,WAAW,EAAqC,MAAM,mBAAmB,CAAC;AAEjH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACH,wBAAgB,QAAQ,CAAC,MAAM,SAAS,MAAM,EAAE,YAAY,SAAS,MAAM,MAAM,EAC7E,YAAY,EAAE,YAAY,EAC1B,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,GAC/C,WAAW,CAAC,MAAM,CAAC,CAErB"}
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.property = void 0;
4
+ const core_1 = require("@serenity-js/core");
5
+ /**
6
+ * Creates an {@apilink Expectation|expectation} that is met when the value of
7
+ * the `actual[propertyName]` meets the `expectation`.
8
+ *
9
+ * ## Ensuring that an array has an item
10
+ *
11
+ * ```ts
12
+ * import { actorCalled } from '@serenity-js/core'
13
+ * import { Ensure, property } from '@serenity-js/assertions'
14
+ *
15
+ * const list = [ 'hello', 'world' ]
16
+ *
17
+ * await actorCalled('Ester').attemptsTo(
18
+ * Ensure.that(list, property(0, isPresent())),
19
+ * )
20
+ * ```
21
+ *
22
+ * ## Ensuring that the property meets an expectation
23
+ *
24
+ * ```ts
25
+ * import { actorCalled } from '@serenity-js/core'
26
+ * import { Ensure, property, equals } from '@serenity-js/assertions'
27
+ *
28
+ * const list = [ 'hello', 'world' ]
29
+ *
30
+ * await actorCalled('Ester').attemptsTo(
31
+ * Ensure.that(list, property('length', equals(2))),
32
+ * )
33
+ * ```
34
+ *
35
+ * ## Asserting on a list of objects
36
+ *
37
+ * ```ts
38
+ * import { actorCalled } from '@serenity-js/core'
39
+ * import { Ensure, property, equals } from '@serenity-js/assertions'
40
+ *
41
+ * const developers = [{
42
+ * name: 'Jan',
43
+ * id: '@jan-molak',
44
+ * }, {
45
+ * name: 'John',
46
+ * id: '@wakaleo',
47
+ * }]
48
+ *
49
+ * await actorCalled('Ester').attemptsTo(
50
+ * Ensure.that(
51
+ * developers,
52
+ * containItemsWhereEachItem(
53
+ * property('id', startsWith('@'))
54
+ * ),
55
+ * ),
56
+ * )
57
+ * ```
58
+ *
59
+ * @param propertyName
60
+ * @param expectation
61
+ *
62
+ * @group Expectations
63
+ */
64
+ function property(propertyName, expectation) {
65
+ return new HasProperty(propertyName, expectation);
66
+ }
67
+ exports.property = property;
68
+ /**
69
+ * @package
70
+ */
71
+ class HasProperty extends core_1.Expectation {
72
+ constructor(propertyName, expectation) {
73
+ const subject = `have property ${String(propertyName)} that does ${expectation}`;
74
+ super(subject, async (actor, actual) => {
75
+ const actualValue = await actor.answer(actual);
76
+ const outcome = await actor.answer(expectation.isMetFor(actualValue[propertyName]));
77
+ return outcome instanceof core_1.ExpectationMet
78
+ ? new core_1.ExpectationMet(subject, outcome.expected, actualValue)
79
+ : new core_1.ExpectationNotMet(subject, outcome.expected, actualValue);
80
+ });
81
+ this.propertyName = propertyName;
82
+ }
83
+ }
84
+ //# sourceMappingURL=property.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"property.js","sourceRoot":"","sources":["../../src/expectations/property.ts"],"names":[],"mappings":";;;AAAA,4CAAiH;AAEjH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACH,SAAgB,QAAQ,CACpB,YAA0B,EAC1B,WAA8C;IAE9C,OAAO,IAAI,WAAW,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC;AACtD,CAAC;AALD,4BAKC;AAED;;GAEG;AACH,MAAM,WAAsE,SAAQ,kBAAmB;IACnG,YACqB,YAA0B,EAC3C,WAA8C;QAE9C,MAAM,OAAO,GAAG,iBAAkB,MAAM,CAAC,YAAY,CAAE,cAAe,WAAY,EAAE,CAAC;QACrF,KAAK,CACD,OAAO,EACP,KAAK,EAAE,KAAuB,EAAE,MAA0B,EAAE,EAAE;YAC1D,MAAM,WAAW,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAC/C,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;YAEpF,OAAO,OAAO,YAAY,qBAAc;gBACpC,CAAC,CAAC,IAAI,qBAAc,CAAc,OAAO,EAAE,OAAO,CAAC,QAAQ,EAAE,WAAW,CAAC;gBACzE,CAAC,CAAC,IAAI,wBAAiB,CAAc,OAAO,EAAE,OAAO,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;QACrF,CAAC,CACJ,CAAC;QAde,iBAAY,GAAZ,YAAY,CAAc;IAe/C,CAAC;CACJ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@serenity-js/assertions",
3
- "version": "3.0.0-rc.26",
3
+ "version": "3.0.0-rc.28",
4
4
  "description": "Screenplay-style assertion library",
5
5
  "author": {
6
6
  "name": "Jan Molak",
@@ -43,7 +43,7 @@
43
43
  "npm": "^6 || ^7 || ^8"
44
44
  },
45
45
  "dependencies": {
46
- "@serenity-js/core": "3.0.0-rc.26",
46
+ "@serenity-js/core": "3.0.0-rc.28",
47
47
  "tiny-types": "^1.19.0"
48
48
  },
49
49
  "devDependencies": {
@@ -51,8 +51,9 @@
51
51
  "@types/chai": "^4.3.3",
52
52
  "@types/mocha": "^9.1.1",
53
53
  "mocha": "^10.0.0",
54
+ "nyc": "15.1.0",
54
55
  "ts-node": "^10.9.1",
55
56
  "typescript": "^4.7.4"
56
57
  },
57
- "gitHead": "ff528f67829479719afbae50a162e76d731334d5"
58
+ "gitHead": "453c93b1337518956c0052e61201fc2b100e0273"
58
59
  }
package/src/Ensure.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import {
2
+ Activity,
2
3
  Answerable,
3
4
  AnswersQuestions,
4
5
  AssertionError,
@@ -14,6 +15,7 @@ import {
14
15
  RuntimeError,
15
16
  UsesAbilities,
16
17
  } from '@serenity-js/core';
18
+ import { FileSystemLocation } from '@serenity-js/core/lib/io';
17
19
  import { inspected } from '@serenity-js/core/lib/io/inspected';
18
20
  import { Artifact, AssertionReport, Name } from '@serenity-js/core/lib/model';
19
21
  import { match } from 'tiny-types';
@@ -77,18 +79,20 @@ export class Ensure<Actual> extends Interaction {
77
79
  * @returns {Ensure<Actual_Type>}
78
80
  */
79
81
  static that<Actual_Type>(actual: Answerable<Actual_Type>, expectation: Expectation<Actual_Type>): Ensure<Actual_Type> {
80
- return new Ensure(actual, expectation);
82
+ return new Ensure(actual, expectation, Activity.callerLocation(5));
81
83
  }
82
84
 
83
85
  /**
84
86
  * @param actual
85
87
  * @param expectation
88
+ * @param location
86
89
  */
87
- constructor(
90
+ protected constructor(
88
91
  protected readonly actual: Answerable<Actual>,
89
92
  protected readonly expectation: Expectation<Actual>,
93
+ location: FileSystemLocation,
90
94
  ) {
91
- super();
95
+ super(d`#actor ensures that ${ actual } does ${ expectation }`, location);
92
96
  }
93
97
 
94
98
  /**
@@ -109,13 +113,6 @@ export class Ensure<Actual> extends Interaction {
109
113
  });
110
114
  }
111
115
 
112
- /**
113
- * @inheritDoc
114
- */
115
- toString(): string {
116
- return d`#actor ensures that ${ this.actual } does ${ this.expectation }`;
117
- }
118
-
119
116
  /**
120
117
  * Overrides the default {@apilink AssertionError} thrown when
121
118
  * the actual value does not meet the expectation.
@@ -168,7 +165,7 @@ class EnsureOrFailWithCustomError<Actual> extends Ensure<Actual> {
168
165
  private readonly typeOfRuntimeError: new (message: string, cause?: Error) => RuntimeError,
169
166
  private readonly message?: string,
170
167
  ) {
171
- super(actual, expectation);
168
+ super(actual, expectation, Activity.callerLocation(6));
172
169
  }
173
170
 
174
171
  protected errorForOutcome(outcome: ExpectationOutcome<any, Actual>): RuntimeError {
@@ -16,4 +16,5 @@ export * from './isTrue';
16
16
  export * from './matches';
17
17
  export * from './not';
18
18
  export * from './or';
19
+ export * from './property';
19
20
  export * from './startsWith';
@@ -0,0 +1,90 @@
1
+ import { Answerable, AnswersQuestions, Expectation, ExpectationMet, ExpectationNotMet } from '@serenity-js/core';
2
+
3
+ /**
4
+ * Creates an {@apilink Expectation|expectation} that is met when the value of
5
+ * the `actual[propertyName]` meets the `expectation`.
6
+ *
7
+ * ## Ensuring that an array has an item
8
+ *
9
+ * ```ts
10
+ * import { actorCalled } from '@serenity-js/core'
11
+ * import { Ensure, property } from '@serenity-js/assertions'
12
+ *
13
+ * const list = [ 'hello', 'world' ]
14
+ *
15
+ * await actorCalled('Ester').attemptsTo(
16
+ * Ensure.that(list, property(0, isPresent())),
17
+ * )
18
+ * ```
19
+ *
20
+ * ## Ensuring that the property meets an expectation
21
+ *
22
+ * ```ts
23
+ * import { actorCalled } from '@serenity-js/core'
24
+ * import { Ensure, property, equals } from '@serenity-js/assertions'
25
+ *
26
+ * const list = [ 'hello', 'world' ]
27
+ *
28
+ * await actorCalled('Ester').attemptsTo(
29
+ * Ensure.that(list, property('length', equals(2))),
30
+ * )
31
+ * ```
32
+ *
33
+ * ## Asserting on a list of objects
34
+ *
35
+ * ```ts
36
+ * import { actorCalled } from '@serenity-js/core'
37
+ * import { Ensure, property, equals } from '@serenity-js/assertions'
38
+ *
39
+ * const developers = [{
40
+ * name: 'Jan',
41
+ * id: '@jan-molak',
42
+ * }, {
43
+ * name: 'John',
44
+ * id: '@wakaleo',
45
+ * }]
46
+ *
47
+ * await actorCalled('Ester').attemptsTo(
48
+ * Ensure.that(
49
+ * developers,
50
+ * containItemsWhereEachItem(
51
+ * property('id', startsWith('@'))
52
+ * ),
53
+ * ),
54
+ * )
55
+ * ```
56
+ *
57
+ * @param propertyName
58
+ * @param expectation
59
+ *
60
+ * @group Expectations
61
+ */
62
+ export function property<Actual extends object, PropertyName extends keyof Actual>(
63
+ propertyName: PropertyName,
64
+ expectation: Expectation<Actual[PropertyName]>
65
+ ): Expectation<Actual> {
66
+ return new HasProperty(propertyName, expectation);
67
+ }
68
+
69
+ /**
70
+ * @package
71
+ */
72
+ class HasProperty<Actual extends object, PropertyName extends keyof Actual> extends Expectation<Actual> {
73
+ constructor(
74
+ private readonly propertyName: PropertyName,
75
+ expectation: Expectation<Actual[PropertyName]>,
76
+ ) {
77
+ const subject = `have property ${ String(propertyName) } that does ${ expectation }`;
78
+ super(
79
+ subject,
80
+ async (actor: AnswersQuestions, actual: Answerable<Actual>) => {
81
+ const actualValue = await actor.answer(actual);
82
+ const outcome = await actor.answer(expectation.isMetFor(actualValue[propertyName]));
83
+
84
+ return outcome instanceof ExpectationMet
85
+ ? new ExpectationMet<any, Actual>(subject, outcome.expected, actualValue)
86
+ : new ExpectationNotMet<any, Actual>(subject, outcome.expected, actualValue);
87
+ },
88
+ );
89
+ }
90
+ }