@serenity-js/assertions 3.0.0-rc.9 → 3.0.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.
Files changed (125) hide show
  1. package/CHANGELOG.md +83 -1891
  2. package/README.md +21 -21
  3. package/lib/Ensure.d.ts +75 -84
  4. package/lib/Ensure.d.ts.map +1 -0
  5. package/lib/Ensure.js +103 -123
  6. package/lib/Ensure.js.map +1 -1
  7. package/lib/EnsureEventually.d.ts +97 -0
  8. package/lib/EnsureEventually.d.ts.map +1 -0
  9. package/lib/EnsureEventually.js +143 -0
  10. package/lib/EnsureEventually.js.map +1 -0
  11. package/lib/expectations/and.d.ts +22 -1
  12. package/lib/expectations/and.d.ts.map +1 -0
  13. package/lib/expectations/and.js +30 -5
  14. package/lib/expectations/and.js.map +1 -1
  15. package/lib/expectations/contain.d.ts +27 -2
  16. package/lib/expectations/contain.d.ts.map +1 -0
  17. package/lib/expectations/contain.js +25 -5
  18. package/lib/expectations/contain.js.map +1 -1
  19. package/lib/expectations/containAtLeastOneItemThat.d.ts +23 -1
  20. package/lib/expectations/containAtLeastOneItemThat.d.ts.map +1 -0
  21. package/lib/expectations/containAtLeastOneItemThat.js +29 -7
  22. package/lib/expectations/containAtLeastOneItemThat.js.map +1 -1
  23. package/lib/expectations/containItemsWhereEachItem.d.ts +22 -0
  24. package/lib/expectations/containItemsWhereEachItem.d.ts.map +1 -0
  25. package/lib/expectations/containItemsWhereEachItem.js +29 -7
  26. package/lib/expectations/containItemsWhereEachItem.js.map +1 -1
  27. package/lib/expectations/endsWith.d.ts +22 -2
  28. package/lib/expectations/endsWith.d.ts.map +1 -0
  29. package/lib/expectations/endsWith.js +20 -5
  30. package/lib/expectations/endsWith.js.map +1 -1
  31. package/lib/expectations/equals.d.ts +28 -2
  32. package/lib/expectations/equals.d.ts.map +1 -0
  33. package/lib/expectations/equals.js +26 -5
  34. package/lib/expectations/equals.js.map +1 -1
  35. package/lib/expectations/includes.d.ts +22 -2
  36. package/lib/expectations/includes.d.ts.map +1 -0
  37. package/lib/expectations/includes.js +20 -5
  38. package/lib/expectations/includes.js.map +1 -1
  39. package/lib/expectations/index.d.ts +3 -0
  40. package/lib/expectations/index.d.ts.map +1 -0
  41. package/lib/expectations/index.js +7 -1
  42. package/lib/expectations/index.js.map +1 -1
  43. package/lib/expectations/isAfter.d.ts +42 -2
  44. package/lib/expectations/isAfter.d.ts.map +1 -0
  45. package/lib/expectations/isAfter.js +40 -5
  46. package/lib/expectations/isAfter.js.map +1 -1
  47. package/lib/expectations/isBefore.d.ts +42 -2
  48. package/lib/expectations/isBefore.d.ts.map +1 -0
  49. package/lib/expectations/isBefore.js +40 -5
  50. package/lib/expectations/isBefore.js.map +1 -1
  51. package/lib/expectations/isCloseTo.d.ts +24 -0
  52. package/lib/expectations/isCloseTo.d.ts.map +1 -0
  53. package/lib/expectations/isCloseTo.js +37 -0
  54. package/lib/expectations/isCloseTo.js.map +1 -0
  55. package/lib/expectations/isFalse.d.ts +19 -0
  56. package/lib/expectations/isFalse.d.ts.map +1 -0
  57. package/lib/expectations/isFalse.js +18 -0
  58. package/lib/expectations/isFalse.js.map +1 -1
  59. package/lib/expectations/isGreaterThan.d.ts +45 -2
  60. package/lib/expectations/isGreaterThan.d.ts.map +1 -0
  61. package/lib/expectations/isGreaterThan.js +43 -5
  62. package/lib/expectations/isGreaterThan.js.map +1 -1
  63. package/lib/expectations/isLessThan.d.ts +45 -2
  64. package/lib/expectations/isLessThan.d.ts.map +1 -0
  65. package/lib/expectations/isLessThan.js +43 -5
  66. package/lib/expectations/isLessThan.js.map +1 -1
  67. package/lib/expectations/isPresent.d.ts +58 -8
  68. package/lib/expectations/isPresent.d.ts.map +1 -0
  69. package/lib/expectations/isPresent.js +60 -11
  70. package/lib/expectations/isPresent.js.map +1 -1
  71. package/lib/expectations/isTrue.d.ts +19 -0
  72. package/lib/expectations/isTrue.d.ts.map +1 -0
  73. package/lib/expectations/isTrue.js +18 -0
  74. package/lib/expectations/isTrue.js.map +1 -1
  75. package/lib/expectations/matches.d.ts +22 -2
  76. package/lib/expectations/matches.d.ts.map +1 -0
  77. package/lib/expectations/matches.js +20 -5
  78. package/lib/expectations/matches.js.map +1 -1
  79. package/lib/expectations/not.d.ts +23 -1
  80. package/lib/expectations/not.d.ts.map +1 -0
  81. package/lib/expectations/not.js +32 -10
  82. package/lib/expectations/not.js.map +1 -1
  83. package/lib/expectations/or.d.ts +22 -1
  84. package/lib/expectations/or.d.ts.map +1 -0
  85. package/lib/expectations/or.js +29 -9
  86. package/lib/expectations/or.js.map +1 -1
  87. package/lib/expectations/property.d.ts +62 -0
  88. package/lib/expectations/property.d.ts.map +1 -0
  89. package/lib/expectations/property.js +85 -0
  90. package/lib/expectations/property.js.map +1 -0
  91. package/lib/expectations/startsWith.d.ts +22 -2
  92. package/lib/expectations/startsWith.d.ts.map +1 -0
  93. package/lib/expectations/startsWith.js +20 -5
  94. package/lib/expectations/startsWith.js.map +1 -1
  95. package/lib/index.d.ts +2 -1
  96. package/lib/index.d.ts.map +1 -0
  97. package/lib/index.js +6 -5
  98. package/lib/index.js.map +1 -1
  99. package/package.json +19 -42
  100. package/src/Ensure.ts +110 -136
  101. package/src/EnsureEventually.ts +173 -0
  102. package/src/expectations/and.ts +38 -14
  103. package/src/expectations/contain.ts +30 -5
  104. package/src/expectations/containAtLeastOneItemThat.ts +40 -10
  105. package/src/expectations/containItemsWhereEachItem.ts +35 -5
  106. package/src/expectations/endsWith.ts +25 -5
  107. package/src/expectations/equals.ts +31 -5
  108. package/src/expectations/includes.ts +25 -5
  109. package/src/expectations/index.ts +2 -0
  110. package/src/expectations/isAfter.ts +45 -5
  111. package/src/expectations/isBefore.ts +45 -5
  112. package/src/expectations/isCloseTo.ts +40 -0
  113. package/src/expectations/isFalse.ts +19 -1
  114. package/src/expectations/isGreaterThan.ts +48 -5
  115. package/src/expectations/isLessThan.ts +48 -5
  116. package/src/expectations/isPresent.ts +62 -13
  117. package/src/expectations/isTrue.ts +19 -1
  118. package/src/expectations/matches.ts +25 -5
  119. package/src/expectations/not.ts +28 -5
  120. package/src/expectations/or.ts +28 -6
  121. package/src/expectations/property.ts +93 -0
  122. package/src/expectations/startsWith.ts +25 -5
  123. package/src/index.ts +1 -1
  124. package/tsconfig.build.json +10 -0
  125. package/tsconfig.eslint.json +0 -10
@@ -2,16 +2,41 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.or = void 0;
4
4
  const core_1 = require("@serenity-js/core");
5
- function or(...assertions) {
6
- return new Or(assertions);
5
+ /**
6
+ * Creates an {@apilink Expectation|expectation} that is met when at least one of the `expectations` is met for the given actual value.
7
+ *
8
+ * Use `or` to combine several expectations using logical "or",
9
+ *
10
+ * ## Combining several expectations
11
+ *
12
+ * ```ts
13
+ * import { actorCalled } from '@serenity-js/core'
14
+ * import { Ensure, or, startsWith } from '@serenity-js/assertions'
15
+ *
16
+ * await actorCalled('Ester').attemptsTo(
17
+ * Ensure.that('Hello World!', or(startsWith('Hello'), startsWith('Hi'))),
18
+ * )
19
+ * ```
20
+ *
21
+ * @param expectations
22
+ *
23
+ * @group Expectations
24
+ */
25
+ function or(...expectations) {
26
+ return new Or(expectations);
7
27
  }
8
28
  exports.or = or;
9
29
  /**
10
30
  * @package
11
31
  */
12
32
  class Or extends core_1.Expectation {
33
+ static subjectFor(expectations) {
34
+ return expectations
35
+ .map(expectation => expectation.toString())
36
+ .join(Or.Separator);
37
+ }
13
38
  constructor(expectations) {
14
- super(Or.descriptionFor(expectations), async (actor, actual) => {
39
+ super('or', Or.subjectFor(expectations), async (actor, actual) => {
15
40
  if (!expectations || expectations.length === 0) {
16
41
  throw new core_1.LogicError(`No expectations provided to or()`);
17
42
  }
@@ -22,15 +47,10 @@ class Or extends core_1.Expectation {
22
47
  return outcome;
23
48
  }
24
49
  }
25
- return new core_1.ExpectationNotMet(Or.descriptionFor(expectations), outcome.expected, outcome.actual);
50
+ return new core_1.ExpectationNotMet(Or.subjectFor(expectations), outcome.expectation, outcome.expected, outcome.actual);
26
51
  });
27
52
  this.expectations = expectations;
28
53
  }
29
- static descriptionFor(expectations) {
30
- return expectations
31
- .map(expectation => expectation.toString())
32
- .join(Or.Separator);
33
- }
34
54
  }
35
55
  Or.Separator = ' or ';
36
56
  //# sourceMappingURL=or.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"or.js","sourceRoot":"","sources":["../../src/expectations/or.ts"],"names":[],"mappings":";;;AAAA,4CAAiJ;AAEjJ,SAAgB,EAAE,CAAS,GAAG,UAAsC;IAChE,OAAO,IAAI,EAAE,CAAC,UAAU,CAAC,CAAC;AAC9B,CAAC;AAFD,gBAEC;AAED;;GAEG;AACH,MAAM,EAAW,SAAQ,kBAAmB;IASxC,YAA6B,YAAwC;QACjE,KAAK,CACD,EAAE,CAAC,cAAc,CAAC,YAAY,CAAC,EAC/B,KAAK,EAAE,KAAuB,EAAE,MAA0B,EAAE,EAAE;YAC1D,IAAI,CAAE,YAAY,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE;gBAC7C,MAAM,IAAI,iBAAU,CAAC,kCAAkC,CAAC,CAAC;aAC5D;YAED,IAAI,OAA4C,CAAC;YACjD,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE;gBACpC,OAAO,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;gBAE3D,IAAI,OAAO,YAAY,qBAAc,EAAE;oBACnC,OAAO,OAAO,CAAC;iBAClB;aACJ;YAED,OAAO,IAAI,wBAAiB,CACxB,EAAE,CAAC,cAAc,CAAC,YAAY,CAAC,EAC/B,OAAO,CAAC,QAAQ,EAChB,OAAO,CAAC,MAAM,CACjB,CAAC;QACN,CAAC,CACJ,CAAC;QAvBuB,iBAAY,GAAZ,YAAY,CAA4B;IAwBrE,CAAC;IA9BO,MAAM,CAAC,cAAc,CAAI,YAAmC;QAChE,OAAO,YAAY;aACd,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC;aAC1C,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC;IAC5B,CAAC;;AANuB,YAAS,GAAG,MAAM,CAAC"}
1
+ {"version":3,"file":"or.js","sourceRoot":"","sources":["../../src/expectations/or.ts"],"names":[],"mappings":";;;AAAA,4CAAiJ;AAEjJ;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,EAAE,CAAc,GAAG,YAA6C;IAC5E,OAAO,IAAI,EAAE,CAAC,YAAY,CAAC,CAAC;AAChC,CAAC;AAFD,gBAEC;AAED;;GAEG;AACH,MAAM,EAAW,SAAQ,kBAAmB;IAGhC,MAAM,CAAC,UAAU,CAAI,YAAmC;QAC5D,OAAO,YAAY;aACd,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC;aAC1C,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC;IAC5B,CAAC;IAED,YAA6B,YAAwC;QACjE,KAAK,CACD,IAAI,EACJ,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAC3B,KAAK,EAAE,KAAuB,EAAE,MAA0B,EAAE,EAAE;YAC1D,IAAI,CAAE,YAAY,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE;gBAC7C,MAAM,IAAI,iBAAU,CAAC,kCAAkC,CAAC,CAAC;aAC5D;YAED,IAAI,OAA2B,CAAC;YAChC,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE;gBACpC,OAAO,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;gBAE3D,IAAI,OAAO,YAAY,qBAAc,EAAE;oBACnC,OAAO,OAAO,CAAC;iBAClB;aACJ;YAED,OAAO,IAAI,wBAAiB,CACxB,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAC3B,OAAO,CAAC,WAAW,EACnB,OAAO,CAAC,QAAQ,EAChB,OAAO,CAAC,MAAM,CACjB,CAAC;QACN,CAAC,CACJ,CAAC;QAzBuB,iBAAY,GAAZ,YAAY,CAA4B;IA0BrE,CAAC;;AAlCuB,YAAS,GAAG,MAAM,CAAC"}
@@ -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,EAAyD,MAAM,mBAAmB,CAAC;AAErI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,85 @@
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('property', subject, async (actor, actual) => {
75
+ const actualValue = await actor.answer(actual);
76
+ const outcome = await actor.answer(expectation.isMetFor(actualValue[propertyName]));
77
+ const expectationDetails = core_1.ExpectationDetails.of('property', String(propertyName), outcome.expectation);
78
+ return outcome instanceof core_1.ExpectationMet
79
+ ? new core_1.ExpectationMet(subject, expectationDetails, outcome.expected, outcome.actual)
80
+ : new core_1.ExpectationNotMet(subject, expectationDetails, outcome.expected, outcome.actual);
81
+ });
82
+ this.propertyName = propertyName;
83
+ }
84
+ }
85
+ //# sourceMappingURL=property.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"property.js","sourceRoot":"","sources":["../../src/expectations/property.ts"],"names":[],"mappings":";;;AAAA,4CAAqI;AAErI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,UAAU,EACV,OAAO,EACP,KAAK,EAAE,KAAuB,EAAE,MAA0B,EAAE,EAAE;YAC1D,MAAM,WAAW,GAAK,MAAM,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YACjD,MAAM,OAAO,GAAS,MAAM,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;YAE1F,MAAM,kBAAkB,GAAG,yBAAkB,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;YAExG,OAAO,OAAO,YAAY,qBAAc;gBACpC,CAAC,CAAC,IAAI,qBAAc,CAAC,OAAO,EAAE,kBAAkB,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC;gBACnF,CAAC,CAAC,IAAI,wBAAiB,CAAC,OAAO,EAAE,kBAAkB,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;QAC/F,CAAC,CACJ,CAAC;QAjBe,iBAAY,GAAZ,YAAY,CAAc;IAkB/C,CAAC;CACJ"}
@@ -1,2 +1,22 @@
1
- import { Answerable, Expectation } from '@serenity-js/core';
2
- export declare function startsWith(expected: Answerable<string>): Expectation<string>;
1
+ import { Expectation } from '@serenity-js/core';
2
+ /**
3
+ * Creates an {@apilink Expectation|expectation} that is met when the actual `string` value
4
+ * starts with the resolved value of `expected`.
5
+ *
6
+ * ## Ensuring that a given string starts with an expected substring
7
+ *
8
+ * ```ts
9
+ * import { actorCalled } from '@serenity-js/core'
10
+ * import { Ensure, startsWith } from '@serenity-js/assertions'
11
+ *
12
+ * await actorCalled('Ester').attemptsTo(
13
+ * Ensure.that('Hello World!', startsWith('Hello')),
14
+ * )
15
+ * ```
16
+ *
17
+ * @param expected
18
+ *
19
+ * @group Expectations
20
+ */
21
+ export declare const startsWith: (expected: import("@serenity-js/core").Answerable<string>) => Expectation<string>;
22
+ //# sourceMappingURL=startsWith.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"startsWith.d.ts","sourceRoot":"","sources":["../../src/expectations/startsWith.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,UAAU,mFAItB,CAAA"}
@@ -2,9 +2,24 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.startsWith = void 0;
4
4
  const core_1 = require("@serenity-js/core");
5
- function startsWith(expected) {
6
- return core_1.Expectation.thatActualShould('start with', expected)
7
- .soThat((actualValue, expectedValue) => actualValue.startsWith(expectedValue));
8
- }
9
- exports.startsWith = startsWith;
5
+ /**
6
+ * Creates an {@apilink Expectation|expectation} that is met when the actual `string` value
7
+ * starts with the resolved value of `expected`.
8
+ *
9
+ * ## Ensuring that a given string starts with an expected substring
10
+ *
11
+ * ```ts
12
+ * import { actorCalled } from '@serenity-js/core'
13
+ * import { Ensure, startsWith } from '@serenity-js/assertions'
14
+ *
15
+ * await actorCalled('Ester').attemptsTo(
16
+ * Ensure.that('Hello World!', startsWith('Hello')),
17
+ * )
18
+ * ```
19
+ *
20
+ * @param expected
21
+ *
22
+ * @group Expectations
23
+ */
24
+ exports.startsWith = core_1.Expectation.define('startsWith', 'start with', (actual, expected) => actual.startsWith(expected));
10
25
  //# sourceMappingURL=startsWith.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"startsWith.js","sourceRoot":"","sources":["../../src/expectations/startsWith.ts"],"names":[],"mappings":";;;AAAA,4CAA4D;AAE5D,SAAgB,UAAU,CAAC,QAA4B;IACnD,OAAO,kBAAW,CAAC,gBAAgB,CAAiB,YAAY,EAAE,QAAQ,CAAC;SACtE,MAAM,CAAC,CAAC,WAAW,EAAE,aAAa,EAAE,EAAE,CAAC,WAAW,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC;AACvF,CAAC;AAHD,gCAGC"}
1
+ {"version":3,"file":"startsWith.js","sourceRoot":"","sources":["../../src/expectations/startsWith.ts"],"names":[],"mappings":";;;AAAA,4CAAgD;AAEhD;;;;;;;;;;;;;;;;;;GAkBG;AACU,QAAA,UAAU,GAAG,kBAAW,CAAC,MAAM,CACxC,YAAY,EAAE,YAAY,EAC1B,CAAC,MAAc,EAAE,QAAgB,EAAE,EAAE,CACjC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAClC,CAAA"}
package/lib/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './Ensure';
2
+ export * from './EnsureEventually';
2
3
  export * from './expectations';
3
- export { Check, Expectation } from '@serenity-js/core';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC"}
package/lib/index.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -10,10 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
15
  };
12
16
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.Expectation = exports.Check = void 0;
14
17
  __exportStar(require("./Ensure"), exports);
18
+ __exportStar(require("./EnsureEventually"), exports);
15
19
  __exportStar(require("./expectations"), exports);
16
- var core_1 = require("@serenity-js/core"); // re-exported to avoid breaking backwards compatibility with tests using 2.24.1
17
- Object.defineProperty(exports, "Check", { enumerable: true, get: function () { return core_1.Check; } });
18
- Object.defineProperty(exports, "Expectation", { enumerable: true, get: function () { return core_1.Expectation; } });
19
20
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAyB;AACzB,iDAA+B;AAC/B,0CAAuD,CAAC,gFAAgF;AAA/H,6FAAA,KAAK,OAAA;AAAE,mGAAA,WAAW,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,qDAAmC;AACnC,iDAA+B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@serenity-js/assertions",
3
- "version": "3.0.0-rc.9",
3
+ "version": "3.0.0",
4
4
  "description": "Screenplay-style assertion library",
5
5
  "author": {
6
6
  "name": "Jan Molak",
@@ -26,58 +26,35 @@
26
26
  "testing"
27
27
  ],
28
28
  "scripts": {
29
- "clean": "rimraf .nyc_output lib target",
30
- "lint": "eslint --ext ts --config ../../.eslintrc.yml .",
31
- "lint:fix": "npm run lint -- --fix",
32
- "test": "nyc --report-dir ../../target/coverage/assertions mocha --config ../../.mocharc.yml 'spec/**/*.spec.*'",
33
- "compile": "tsc --project tsconfig.json",
34
- "site": "esdoc -c .esdoc.js"
29
+ "clean": "rimraf target",
30
+ "test": "nyc mocha --config ../../.mocharc.yml --reporter-options 'mocha-multi=.mocha-reporters.json' 'spec/**/*.spec.*'",
31
+ "compile": "rimraf lib && tsc --project tsconfig.build.json"
35
32
  },
36
33
  "repository": {
37
34
  "type": "git",
38
- "url": "https://github.com/serenity-js/serenity-js.git"
35
+ "url": "https://github.com/serenity-js/serenity-js.git",
36
+ "directory": "packages/assertions"
39
37
  },
40
38
  "bugs": {
41
39
  "url": "https://github.com/serenity-js/serenity-js/issues"
42
40
  },
43
41
  "engines": {
44
- "node": "^14 || ^16",
45
- "npm": "^6 || ^7 || ^8"
42
+ "node": "^14 || ^16 || ^18",
43
+ "npm": "^6 || ^7 || ^8 || ^9"
46
44
  },
47
45
  "dependencies": {
48
- "@serenity-js/core": "3.0.0-rc.9",
49
- "tiny-types": "^1.17.0"
46
+ "@serenity-js/core": "3.0.0",
47
+ "tiny-types": "^1.19.1"
50
48
  },
51
49
  "devDependencies": {
52
- "@documentation/esdoc-template": "3.0.0",
53
50
  "@integration/testing-tools": "3.0.0",
54
- "@types/chai": "^4.3.0",
55
- "@types/mocha": "^9.0.0",
56
- "mocha": "^9.1.3",
57
- "ts-node": "^10.4.0",
58
- "typescript": "^4.5.4"
59
- },
60
- "nyc": {
61
- "include": [
62
- "src/**/*.ts"
63
- ],
64
- "exclude": [
65
- "src/**/*.d.ts",
66
- "lib",
67
- "node_modules",
68
- "spec"
69
- ],
70
- "extension": [
71
- ".ts"
72
- ],
73
- "require": [
74
- "ts-node/register"
75
- ],
76
- "reporter": [
77
- "json"
78
- ],
79
- "cache": true,
80
- "all": true
81
- },
82
- "gitHead": "bc72fce0831fe6c1e4e69d5ca307d7fb5f6d2f0d"
51
+ "@types/chai": "^4.3.4",
52
+ "@types/mocha": "^10.0.1",
53
+ "mocha": "^10.2.0",
54
+ "mocha-multi": "^1.1.7",
55
+ "nyc": "15.1.0",
56
+ "ts-node": "^10.9.1",
57
+ "typescript": "^4.9.5"
58
+ },
59
+ "gitHead": "1c2fffcabd725822e6c93fb4125f5830fa97f56d"
83
60
  }