@serenity-js/core 3.42.1 → 3.43.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 (74) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/esm/Serenity.d.ts +3 -1
  3. package/esm/Serenity.d.ts.map +1 -1
  4. package/esm/Serenity.js +4 -3
  5. package/esm/Serenity.js.map +1 -1
  6. package/esm/screenplay/Actor.d.ts +1 -1
  7. package/esm/screenplay/Actor.d.ts.map +1 -1
  8. package/esm/screenplay/Actor.js +5 -6
  9. package/esm/screenplay/Actor.js.map +1 -1
  10. package/esm/screenplay/abilities/Discardable.d.ts +3 -2
  11. package/esm/screenplay/abilities/Discardable.d.ts.map +1 -1
  12. package/esm/screenplay/abilities/Discardable.js +25 -1
  13. package/esm/screenplay/abilities/Discardable.js.map +1 -1
  14. package/esm/screenplay/abilities/Initialisable.d.ts +4 -3
  15. package/esm/screenplay/abilities/Initialisable.d.ts.map +1 -1
  16. package/esm/screenplay/abilities/Initialisable.js +22 -1
  17. package/esm/screenplay/abilities/Initialisable.js.map +1 -1
  18. package/esm/stage/ActorLifecycleManager.d.ts +191 -0
  19. package/esm/stage/ActorLifecycleManager.d.ts.map +1 -0
  20. package/esm/stage/ActorLifecycleManager.js +255 -0
  21. package/esm/stage/ActorLifecycleManager.js.map +1 -0
  22. package/esm/stage/Stage.d.ts +22 -38
  23. package/esm/stage/Stage.d.ts.map +1 -1
  24. package/esm/stage/Stage.js +61 -117
  25. package/esm/stage/Stage.js.map +1 -1
  26. package/esm/stage/StageManager.d.ts +2 -4
  27. package/esm/stage/StageManager.d.ts.map +1 -1
  28. package/esm/stage/StageManager.js +0 -5
  29. package/esm/stage/StageManager.js.map +1 -1
  30. package/esm/stage/index.d.ts +1 -0
  31. package/esm/stage/index.d.ts.map +1 -1
  32. package/esm/stage/index.js +1 -0
  33. package/esm/stage/index.js.map +1 -1
  34. package/lib/Serenity.d.ts +3 -1
  35. package/lib/Serenity.d.ts.map +1 -1
  36. package/lib/Serenity.js +4 -3
  37. package/lib/Serenity.js.map +1 -1
  38. package/lib/screenplay/Actor.d.ts +1 -1
  39. package/lib/screenplay/Actor.d.ts.map +1 -1
  40. package/lib/screenplay/Actor.js +4 -5
  41. package/lib/screenplay/Actor.js.map +1 -1
  42. package/lib/screenplay/abilities/Discardable.d.ts +3 -2
  43. package/lib/screenplay/abilities/Discardable.d.ts.map +1 -1
  44. package/lib/screenplay/abilities/Discardable.js +27 -0
  45. package/lib/screenplay/abilities/Discardable.js.map +1 -1
  46. package/lib/screenplay/abilities/Initialisable.d.ts +4 -3
  47. package/lib/screenplay/abilities/Initialisable.d.ts.map +1 -1
  48. package/lib/screenplay/abilities/Initialisable.js +24 -0
  49. package/lib/screenplay/abilities/Initialisable.js.map +1 -1
  50. package/lib/stage/ActorLifecycleManager.d.ts +191 -0
  51. package/lib/stage/ActorLifecycleManager.d.ts.map +1 -0
  52. package/lib/stage/ActorLifecycleManager.js +259 -0
  53. package/lib/stage/ActorLifecycleManager.js.map +1 -0
  54. package/lib/stage/Stage.d.ts +22 -38
  55. package/lib/stage/Stage.d.ts.map +1 -1
  56. package/lib/stage/Stage.js +57 -113
  57. package/lib/stage/Stage.js.map +1 -1
  58. package/lib/stage/StageManager.d.ts +2 -4
  59. package/lib/stage/StageManager.d.ts.map +1 -1
  60. package/lib/stage/StageManager.js +0 -5
  61. package/lib/stage/StageManager.js.map +1 -1
  62. package/lib/stage/index.d.ts +1 -0
  63. package/lib/stage/index.d.ts.map +1 -1
  64. package/lib/stage/index.js +1 -0
  65. package/lib/stage/index.js.map +1 -1
  66. package/package.json +4 -4
  67. package/src/Serenity.ts +5 -2
  68. package/src/screenplay/Actor.ts +6 -9
  69. package/src/screenplay/abilities/Discardable.ts +7 -2
  70. package/src/screenplay/abilities/Initialisable.ts +10 -3
  71. package/src/stage/ActorLifecycleManager.ts +314 -0
  72. package/src/stage/Stage.ts +87 -165
  73. package/src/stage/StageManager.ts +3 -7
  74. package/src/stage/index.ts +1 -0
package/CHANGELOG.md CHANGED
@@ -3,6 +3,26 @@
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.43.0](https://github.com/serenity-js/serenity-js/compare/v3.42.2...v3.43.0) (2026-05-11)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **core:** introduced Initialisable.isInitialisable and Discardable.isDiscardable ([a8c260d](https://github.com/serenity-js/serenity-js/commit/a8c260db850f8d50f8b289d123fe95c9aa859a5e))
12
+ * **deps:** update dependency semver to v7.8.0 ([c76c7ea](https://github.com/serenity-js/serenity-js/commit/c76c7eaef92c840859fa080494f702f8d32372bc))
13
+
14
+
15
+
16
+
17
+
18
+ ## [3.42.2](https://github.com/serenity-js/serenity-js/compare/v3.42.1...v3.42.2) (2026-04-26)
19
+
20
+ **Note:** Version bump only for package @serenity-js/core
21
+
22
+
23
+
24
+
25
+
6
26
  ## [3.42.1](https://github.com/serenity-js/serenity-js/compare/v3.42.0...v3.42.1) (2026-04-08)
7
27
 
8
28
 
package/esm/Serenity.d.ts CHANGED
@@ -6,6 +6,7 @@ import { type ActivityDetails, CorrelationId, type CorrelationIdFactory } from '
6
6
  import type { Actor, Timestamp } from './screenplay/index.js';
7
7
  import { Clock } from './screenplay/index.js';
8
8
  import type { Cast } from './stage/Cast.js';
9
+ import type { ActorLifecycleManager } from './stage/index.js';
9
10
  /**
10
11
  * @group Serenity
11
12
  */
@@ -22,8 +23,9 @@ export declare class Serenity implements EmitsDomainEvents {
22
23
  * @param clock
23
24
  * @param cwd
24
25
  * @param sceneIdFactory
26
+ * @param actorLifecycleManager - Optional custom ActorLifecycleManager instance
25
27
  */
26
- constructor(clock?: Clock, cwd?: string, sceneIdFactory?: CorrelationIdFactory);
28
+ constructor(clock?: Clock, cwd?: string, sceneIdFactory?: CorrelationIdFactory, actorLifecycleManager?: ActorLifecycleManager);
27
29
  /**
28
30
  * Configures Serenity/JS. Every call to this function
29
31
  * replaces the previous configuration provided,
@@ -1 +1 @@
1
- {"version":3,"file":"Serenity.d.ts","sourceRoot":"","sources":["../src/Serenity.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEpE,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAyE,IAAI,EAAE,MAAM,eAAe,CAAC;AAC5G,OAAO,EAAE,KAAK,eAAe,EAAE,aAAa,EAAE,KAAK,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAClG,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,KAAK,EAAY,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAM5C;;GAEG;AACH,qBAAa,QAAS,YAAW,iBAAiB;IAC9C,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAoC;IACpE,OAAO,CAAC,MAAM,CAAC,yBAAyB,CAA4B;IACpE,OAAO,CAAC,MAAM,CAAC,aAAa,CAA+B;IAE3D,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAQ;IAC9B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;IACxC,OAAO,CAAC,YAAY,CAAiC;IAErD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAc;IAC1C,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAO;IAExC;;;;OAIG;gBAEC,KAAK,GAAE,KAAmB,EAC1B,GAAG,GAAE,MAAsB,EAC3B,cAAc,GAAE,oBAAoC;IAqBxD;;;;;;;OAOG;IACH,SAAS,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI;IAmDvC;;;;;;;;;;;;;;;;;;;;;;;;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cAAc,IAAI,aAAa;IAI/B,mBAAmB,CAAC,eAAe,EAAE,eAAe,GAAG,aAAa;IAIpE,WAAW,CAAC,EAAE,SAAS,YAAY,EAAE,SAAS,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,YAAY,GAAG,EAAE;IAItG;;OAEG;IACH,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAI/B,GAAG,IAAI,IAAI;CAGd"}
package/esm/Serenity.js CHANGED
@@ -4,8 +4,8 @@ import { ClassDescriptionParser, ClassLoader, d, FileSystem, has, ModuleLoader,
4
4
  import { CorrelationId } from './model/index.js';
5
5
  import { Clock, Duration } from './screenplay/index.js';
6
6
  import { Extras } from './stage/Extras.js';
7
+ import { StageManager } from './stage/index.js';
7
8
  import { Stage } from './stage/Stage.js';
8
- import { StageManager } from './stage/StageManager.js';
9
9
  /**
10
10
  * @group Serenity
11
11
  */
@@ -22,9 +22,10 @@ export class Serenity {
22
22
  * @param clock
23
23
  * @param cwd
24
24
  * @param sceneIdFactory
25
+ * @param actorLifecycleManager - Optional custom ActorLifecycleManager instance
25
26
  */
26
- constructor(clock = new Clock(), cwd = process.cwd(), sceneIdFactory = CorrelationId) {
27
- this.stage = new Stage(Serenity.defaultActors, new StageManager(Serenity.defaultCueTimeout, clock), new ErrorFactory(), clock, Serenity.defaultInteractionTimeout, sceneIdFactory);
27
+ constructor(clock = new Clock(), cwd = process.cwd(), sceneIdFactory = CorrelationId, actorLifecycleManager) {
28
+ this.stage = new Stage(Serenity.defaultActors, new StageManager(Serenity.defaultCueTimeout, clock), new ErrorFactory(), clock, Serenity.defaultInteractionTimeout, sceneIdFactory, actorLifecycleManager);
28
29
  this.classLoader = new ClassLoader(new ModuleLoader(cwd), new ClassDescriptionParser());
29
30
  this.workingDirectory = new Path(cwd);
30
31
  this.fileSystem = new FileSystem(this.workingDirectory);
@@ -1 +1 @@
1
- {"version":3,"file":"Serenity.js","sourceRoot":"","sources":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nC,CAAC;IAED,WAAW;QACP,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;IACpC,CAAC;IAED,gBAAgB;QACZ,OAAO,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE,CAAC;IACzC,CAAC;IAED,cAAc;QACV,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,CAAC;IACvC,CAAC;IAED,mBAAmB,CAAC,eAAgC;QAChD,OAAO,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,eAAe,CAAC,CAAC;IAC3D,CAAC;IAED,WAAW,CAA0B,SAAqC,EAAE,OAAqB;QAC7F,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IACtD,CAAC;IAED;;OAEG;IACH,cAAc;QACV,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,CAAC;IACvC,CAAC;IAED,GAAG;QACC,OAAO,IAAI,CAAC,gBAAgB,CAAC;IACjC,CAAC"}
@@ -148,7 +148,7 @@ export declare class Actor implements PerformsActivities, UsesAbilities, CanHave
148
148
  */
149
149
  toJSON(): SerialisedActor;
150
150
  private initialiseAbilities;
151
- private findAbilitiesOfType;
151
+ private findAbilitiesWhere;
152
152
  private findAbilityTo;
153
153
  private acquireAbility;
154
154
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"Actor.d.ts","sourceRoot":"","sources":["../../src/screenplay/Actor.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAG,MAAM,mBAAmB,CAAC;AAC1C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAA8B,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrH,OAAO,EAAE,OAAO,EAAsC,MAAM,sBAAsB,CAAC;AACnF,OAAO,KAA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;CAKnB"}
@@ -2,7 +2,7 @@ import { ConfigurationError, TestCompromisedError } from '../errors/index.js';
2
2
  import { ActivityRelatedArtifactGenerated } from '../events/index.js';
3
3
  import { ValueInspector } from '../io/index.js';
4
4
  import { Name, } from '../model/index.js';
5
- import { Ability, AnswerQuestions, PerformActivities } from './abilities/index.js';
5
+ import { Ability, AnswerQuestions, Discardable, Initialisable, PerformActivities } from './abilities/index.js';
6
6
  /**
7
7
  * **Actors** represent **people** and **external systems** interacting with the system under test.
8
8
  * Their role is to perform [activities](https://serenity-js.org/api/core/class/Activity/) that demonstrate how to accomplish a given goal.
@@ -158,7 +158,7 @@ export class Actor {
158
158
  * [discardable](https://serenity-js.org/api/core/interface/Discardable/) [ability](https://serenity-js.org/api/core/class/Ability/) it's been configured with.
159
159
  */
160
160
  dismiss() {
161
- return this.findAbilitiesOfType('discard')
161
+ return this.findAbilitiesWhere(Discardable.isDiscardable)
162
162
  .reduce((previous, ability) => previous.then(() => ability.discard()), Promise.resolve(void 0));
163
163
  }
164
164
  /**
@@ -183,7 +183,7 @@ export class Actor {
183
183
  };
184
184
  }
185
185
  initialiseAbilities() {
186
- return this.findAbilitiesOfType('initialise', 'isInitialised')
186
+ return this.findAbilitiesWhere(Initialisable.isInitialisable)
187
187
  .filter(ability => !ability.isInitialised())
188
188
  .reduce((previous, ability) => previous
189
189
  .then(() => ability.initialise())
@@ -191,11 +191,10 @@ export class Actor {
191
191
  throw new TestCompromisedError(`${this.name} couldn't initialise the ability to ${ability.constructor.name}`, error);
192
192
  }), Promise.resolve(void 0));
193
193
  }
194
- findAbilitiesOfType(...methodNames) {
194
+ findAbilitiesWhere(filter) {
195
195
  const abilitiesFrom = (map) => Array.from(map.values());
196
- const abilitiesWithDesiredMethods = (ability) => methodNames.every(methodName => typeof (ability[methodName]) === 'function');
197
196
  return abilitiesFrom(this.abilities)
198
- .filter(abilitiesWithDesiredMethods);
197
+ .filter(filter);
199
198
  }
200
199
  findAbilityTo(doSomething) {
201
200
  return this.abilities.get(doSomething.abilityType().name);
@@ -1 +1 @@
1
- {"version":3,"file":"Actor.js","sourceRoot":"","sources":["../../src/screenplay/Actor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EAAE,gCAAgC,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,EAAE,IAAI,GAAG,MAAM,mBAAmB,CAAC;AAG1C,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AASnF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACH,MAAM,OAAO,KAAK;IAeM;IACC;IATrB;;;;OAIG;IACc,SAAS,GAAyB,IAAI,GAAG,EAAmB,CAAC;IAE9E,YACoB,IAAY,EACX,KAAY,EAC7B,YAAuB,EAAE;QAFT,SAAI,GAAJ,IAAI,CAAQ;QACX,UAAK,GAAL,KAAK,CAAO;QAG7B;YACI,IAAI,iBAAiB,CAAC,IAAI,EAAE,KAAK,CAAC;YAClC,IAAI,eAAe,CAAC,IAAI,CAAC;YACzB,GAAG,SAAS;SACf,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;IACvD,CAAC;IAED;;;;;;;;;;OAUG;IACH,SAAS,CAAoB,WAA2B;QACpD,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;QAE9C,IAAI,CAAE,KAAK,EAAE,CAAC;YACV,MAAM,IAAI,kBAAkB,CACxB,GAAI,IAAI,CAAC,IAAK,QAAS,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE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face Discardable {
20
+ export declare abstract class Discardable {
21
+ static isDiscardable<T>(value: T): value is T & Discardable;
21
22
  /**
22
23
  * Discards the resources associated with this ability.
23
24
  */
24
- discard(): Promise<void> | void;
25
+ abstract discard(): Promise<void> | void;
25
26
  }
26
27
  //# sourceMappingURL=Discardable.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Discardable.d.ts","sourceRoot":"","sources":["../../../src/screenplay/abilities/Discardable.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,WAAW;IAExB;;OAEG;IACH,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CACnC"}
1
+ {"version":3,"file":"Discardable.d.ts","sourceRoot":"","sources":["../../../src/screenplay/abilities/Discardable.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,8BAAsB,WAAW;IAE7B,MAAM,CAAC,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,KAAK,IAAI,CAAC,GAAG,WAAW;IAK3D;;OAEG;IACH,QAAQ,CAAC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;CAC3C"}
@@ -1,2 +1,26 @@
1
- export {};
1
+ /**
2
+ * An interface to be implemented by any [`Ability`](https://serenity-js.org/api/core/class/Ability/) that needs to free up
3
+ * the resources it uses, e.g. disconnect from a database.
4
+ *
5
+ * This [`Discardable.discard`](https://serenity-js.org/api/core/interface/Discardable/#discard) method is invoked directly by the [actor](https://serenity-js.org/api/core/class/Actor/), and indirectly by the [stage](https://serenity-js.org/api/core/class/Stage/):
6
+ * - when [SceneFinishes](https://serenity-js.org/api/core-events/class/SceneFinishes/), for actors instantiated after [SceneStarts](https://serenity-js.org/api/core-events/class/SceneStarts/) - e.g. within a test scenario or in a "before each" hook
7
+ * - when [`TestRunFinishes`](https://serenity-js.org/api/core-events/class/TestRunFinishes/), for actors instantiated before [SceneStarts](https://serenity-js.org/api/core-events/class/SceneStarts/) - e.g. in a "before all" hook
8
+ *
9
+ * Note that events such as [SceneFinishes](https://serenity-js.org/api/core-events/class/SceneFinishes/) and [`TestRunFinishes`](https://serenity-js.org/api/core-events/class/TestRunFinishes/) are emitted by Serenity/JS test runner adapters,
10
+ * such as `@serenity-js/cucumber`, `@serenity-js/mocha`, `@serenity-js/jasmine`, and so on.
11
+ * Consult their respective readmes to learn how to register them with your test runner of choice.
12
+ *
13
+ * ## Learn more
14
+ * - [`Ability`](https://serenity-js.org/api/core/class/Ability/)
15
+ * - [`AbilityType`](https://serenity-js.org/api/core/#AbilityType)
16
+ * - [`Initialisable`](https://serenity-js.org/api/core/interface/Initialisable/)
17
+ *
18
+ * @group Abilities
19
+ */
20
+ export class Discardable {
21
+ static isDiscardable(value) {
22
+ return typeof (value['discard']) === 'function'
23
+ && value['discard'].length === 0;
24
+ }
25
+ }
2
26
  //# sourceMappingURL=Discardable.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Discardable.js","sourceRoot":"","sources":["../../../src/screenplay/abilities/Discardable.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"Discardable.js","sourceRoot":"","sources":["../../../src/screenplay/abilities/Discardable.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,OAAgB,WAAW;IAE7B,MAAM,CAAC,aAAa,CAAI,KAAQ;QAC5B,OAAO,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,KAAK,UAAU;eACxC,KAAK,CAAC,SAAS,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;IACzC,CAAC;CAMJ"}
@@ -12,7 +12,8 @@
12
12
  *
13
13
  * @group Abilities
14
14
  */
15
- export interface Initialisable {
15
+ export declare abstract class Initialisable {
16
+ static isInitialisable<T>(value: T): value is T & Initialisable;
16
17
  /**
17
18
  * Initialises the ability. Invoked whenever [`Actor.attemptsTo`](https://serenity-js.org/api/core/class/Actor/#attemptsTo) method is called,
18
19
  * but **only when** [`Initialisable.isInitialised`](https://serenity-js.org/api/core/interface/Initialisable/#isInitialised) returns false.
@@ -20,7 +21,7 @@ export interface Initialisable {
20
21
  * Make sure to implement [`Initialisable.isInitialised`](https://serenity-js.org/api/core/interface/Initialisable/#isInitialised) so that it returns `true`
21
22
  * when the ability has been successfully initialised.
22
23
  */
23
- initialise(): Promise<void> | void;
24
+ abstract initialise(): Promise<void> | void;
24
25
  /**
25
26
  * Should return `true` when all the resources that the given ability needs
26
27
  * have been initialised. Should return `false` if the [`Actor`](https://serenity-js.org/api/core/class/Actor/) should
@@ -28,6 +29,6 @@ export interface Initialisable {
28
29
  *
29
30
  * @returns {boolean}
30
31
  */
31
- isInitialised(): boolean;
32
+ abstract isInitialised(): boolean;
32
33
  }
33
34
  //# sourceMappingURL=Initialisable.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Initialisable.d.ts","sourceRoot":"","sources":["../../../src/screenplay/abilities/Initialisable.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,aAAa;IAE1B;;;;;;OAMG;IACH,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAEnC;;;;;;OAMG;IACH,aAAa,IAAI,OAAO,CAAC;CAC5B"}
1
+ {"version":3,"file":"Initialisable.d.ts","sourceRoot":"","sources":["../../../src/screenplay/abilities/Initialisable.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,8BAAsB,aAAa;IAE/B,MAAM,CAAC,eAAe,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,KAAK,IAAI,CAAC,GAAG,aAAa;IAO/D;;;;;;OAMG;IACH,QAAQ,CAAC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IAE3C;;;;;;OAMG;IACH,QAAQ,CAAC,aAAa,IAAI,OAAO;CACpC"}
@@ -1,2 +1,23 @@
1
- export {};
1
+ /**
2
+ * An interface to be implemented by any [`Ability`](https://serenity-js.org/api/core/class/Ability/) that needs to initialise
3
+ * the resources it uses, e.g. establish a database connection.
4
+ *
5
+ * The [`Initialisable.initialise`](https://serenity-js.org/api/core/interface/Initialisable/#initialise) method is invoked whenever [`Actor.attemptsTo`](https://serenity-js.org/api/core/class/Actor/#attemptsTo) method is called,
6
+ * but **only when** [`Initialisable.isInitialised`](https://serenity-js.org/api/core/interface/Initialisable/#isInitialised) returns false. This is to avoid initialising abilities more than once.
7
+ *
8
+ * ## Learn more
9
+ * - [`Ability`](https://serenity-js.org/api/core/class/Ability/)
10
+ * - [`AbilityType`](https://serenity-js.org/api/core/#AbilityType)
11
+ * - [`Discardable`](https://serenity-js.org/api/core/interface/Discardable/)
12
+ *
13
+ * @group Abilities
14
+ */
15
+ export class Initialisable {
16
+ static isInitialisable(value) {
17
+ return typeof (value['initialise']) === 'function'
18
+ && value['initialise'].length === 0
19
+ && typeof value['isInitialised'] === 'function'
20
+ && value['isInitialised'].length === 0;
21
+ }
22
+ }
2
23
  //# sourceMappingURL=Initialisable.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Initialisable.js","sourceRoot":"","sources":["../../../src/screenplay/abilities/Initialisable.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"Initialisable.js","sourceRoot":"","sources":["../../../src/screenplay/abilities/Initialisable.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAgB,aAAa;IAE/B,MAAM,CAAC,eAAe,CAAI,KAAQ;QAC9B,OAAO,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,KAAK,UAAU;eAC3C,KAAK,CAAC,YAAY,CAAC,CAAC,MAAM,KAAK,CAAC;eAChC,OAAO,KAAK,CAAC,eAAe,CAAC,KAAK,UAAU;eAC5C,KAAK,CAAC,eAAe,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;IAC/C,CAAC;CAmBJ"}
@@ -0,0 +1,191 @@
1
+ import type { Clock, Duration } from '../screenplay/index.js';
2
+ import { Actor } from '../screenplay/index.js';
3
+ import type { Cast } from './Cast.js';
4
+ import type { Stage } from './Stage.js';
5
+ /**
6
+ * Represents the focus area where actors are tracked.
7
+ *
8
+ * - `'foreground'` - Scene-scoped actors that are dismissed when a scene finishes
9
+ * - `'background'` - Test run-scoped actors that persist across scenes and are dismissed when the test run finishes
10
+ *
11
+ * @group Stage
12
+ */
13
+ export type StageFocus = 'foreground' | 'background';
14
+ /**
15
+ * Manages the lifecycle of [actors](https://serenity-js.org/api/core/class/Actor/) on the [stage](https://serenity-js.org/api/core/class/Stage/),
16
+ * including their creation, retrieval, and tracking of which actors are in the foreground (scene-scoped)
17
+ * versus background (test run-scoped).
18
+ *
19
+ * The `ActorLifecycleManager` is responsible for:
20
+ * - Instantiating and caching actors via the configured [cast](https://serenity-js.org/api/core/class/Cast/)
21
+ * - Tracking which actor is currently in the spotlight (active)
22
+ * - Managing the focus area (foreground vs background) where new actors are created
23
+ * - Providing access to actors for dismissal when scenes or test runs finish
24
+ *
25
+ * ## Default behaviour
26
+ *
27
+ * By default, actors created before the actual test scenario starts, e.g. in beforeAll hooks, are placed in the `'background'` focus area.
28
+ * When a [`SceneStarts`](https://serenity-js.org/api/core-events/class/SceneStarts/) event is announced,
29
+ * the focus switches to `'foreground'`. When a [`SceneFinishes`](https://serenity-js.org/api/core-events/class/SceneFinishes/)
30
+ * event is announced, foreground actors are dismissed, their abilities [discarded](https://serenity-js.org/api/core/interface/Discardable/)
31
+ * and focus returns to `'background'`.
32
+ *
33
+ * ## Custom lifecycle management
34
+ *
35
+ * Test runner adapters like [`@serenity-js/playwright-test`](https://serenity-js.org/api/playwright-test/),
36
+ * where test execution and reporting happen in separate processes, can inject a custom `ActorLifecycleManager` instance
37
+ * to control actor lifecycle programmatically.
38
+ *
39
+ * ```typescript
40
+ * const actorLifecycleManager = new ActorLifecycleManager(cast, clock, interactionTimeout);
41
+ * const serenity = new Serenity(clock, cueTimeout, actorLifecycleManager);
42
+ *
43
+ * // At the start of each test:
44
+ * actorLifecycleManager.switchFocus('foreground');
45
+ * ```
46
+ *
47
+ * ## Learn more
48
+ * - [`Stage`](https://serenity-js.org/api/core/class/Stage/)
49
+ * - [`Cast`](https://serenity-js.org/api/core/class/Cast/)
50
+ * - [`Actor`](https://serenity-js.org/api/core/class/Actor/)
51
+ *
52
+ * @group Stage
53
+ */
54
+ export declare class ActorLifecycleManager {
55
+ protected cast: Cast;
56
+ protected readonly clock: Clock;
57
+ protected interactionTimeout: Duration;
58
+ /**
59
+ * The most recent actor referenced via the {@apilink actor} method
60
+ */
61
+ private currentActor?;
62
+ /**
63
+ * The scene in which the spotlight was last set.
64
+ * Used to detect when the spotlight shifts to a different scene context.
65
+ */
66
+ private currentActorScene;
67
+ private currentFocusValue;
68
+ private actors;
69
+ protected stage: Stage;
70
+ constructor(cast: Cast, clock: Clock, interactionTimeout: Duration);
71
+ /**
72
+ * Configures the manager with new settings.
73
+ *
74
+ * @param options - Configuration options
75
+ * @param options.interactionTimeout - The maximum time to wait for an interaction to complete
76
+ */
77
+ configure({ interactionTimeout }: {
78
+ interactionTimeout: Duration;
79
+ }): void;
80
+ /**
81
+ * Associates this manager with a [`Stage`](https://serenity-js.org/api/core/class/Stage/) instance.
82
+ *
83
+ * This method is called automatically by the `Stage` during construction.
84
+ * It establishes the bidirectional relationship between the manager and the stage,
85
+ * allowing the manager to emit [domain events](https://serenity-js.org/api/core-events/class/DomainEvent/)
86
+ * when actors enter the stage or are spotlighted.
87
+ *
88
+ * @param stage - The Stage instance to associate with this manager
89
+ */
90
+ assignTo(stage: Stage): void;
91
+ /**
92
+ * Configures the manager to use the provided [cast](https://serenity-js.org/api/core/class/Cast/) for preparing actors.
93
+ *
94
+ * @param actors - The cast to use for preparing new actors
95
+ *
96
+ * @throws [`ConfigurationError`](https://serenity-js.org/api/core/class/ConfigurationError/)
97
+ * If the provided cast is not defined or doesn't have a `prepare` method
98
+ */
99
+ engage(actors: Cast): void;
100
+ /**
101
+ * Returns the current [cast](https://serenity-js.org/api/core/class/Cast/) used for preparing actors.
102
+ *
103
+ * @returns The currently configured cast
104
+ */
105
+ currentCast(): Cast;
106
+ /**
107
+ * Instantiates a new [`Actor`](https://serenity-js.org/api/core/class/Actor/) or fetches an existing one
108
+ * identified by their name if they've already been instantiated.
109
+ *
110
+ * When a new actor is instantiated, an [`ActorEntersStage`](https://serenity-js.org/api/core-events/class/ActorEntersStage/)
111
+ * event is announced. When the spotlight shifts to a different actor (or the same actor in a different scene),
112
+ * an [`ActorSpotlighted`](https://serenity-js.org/api/core-events/class/ActorSpotlighted/) event is announced.
113
+ *
114
+ * Actors are first looked up in the `'background'` focus area, then in `'foreground'`.
115
+ * New actors are always created in the current focus area.
116
+ *
117
+ * @param name - Case-sensitive name of the Actor, e.g. `Alice`
118
+ * @returns The actor with the given name
119
+ */
120
+ actor(name: string): Actor;
121
+ private prepareActor;
122
+ private typeOf;
123
+ private existingActorCalled;
124
+ /**
125
+ * Returns `true` if there is an [`Actor`](https://serenity-js.org/api/core/class/Actor/) in the spotlight, `false` otherwise.
126
+ *
127
+ * @returns `true` if an actor is currently spotlighted
128
+ */
129
+ hasActorInTheSpotlight(): boolean;
130
+ /**
131
+ * Returns the last [`Actor`](https://serenity-js.org/api/core/class/Actor/) instantiated
132
+ * via [`actor`](https://serenity-js.org/api/core/class/ActorLifecycleManager/#actor).
133
+ *
134
+ * @returns The currently spotlighted actor
135
+ *
136
+ * @throws [`LogicError`](https://serenity-js.org/api/core/class/LogicError/)
137
+ * If no [`Actor`](https://serenity-js.org/api/core/class/Actor/) has been activated yet
138
+ */
139
+ actorInTheSpotlight(): Actor;
140
+ /**
141
+ * Switches the focus to the specified stage area.
142
+ *
143
+ * Actors created after this call will be added to the specified area.
144
+ * This method is typically called automatically by the [`Stage`](https://serenity-js.org/api/core/class/Stage/)
145
+ * in response to [`SceneStarts`](https://serenity-js.org/api/core-events/class/SceneStarts/) and
146
+ * [`SceneFinishes`](https://serenity-js.org/api/core-events/class/SceneFinishes/) events.
147
+ *
148
+ * Test runner adapters can also call this method directly to control actor lifecycle
149
+ * when scene events are not available (e.g., in Playwright Test where the reporter
150
+ * runs in a separate process).
151
+ *
152
+ * @param focus - The focus area to switch to: `'foreground'` for scene-scoped actors,
153
+ * `'background'` for test run-scoped actors
154
+ */
155
+ switchFocus(focus: StageFocus): void;
156
+ /**
157
+ * Returns the current focus area.
158
+ *
159
+ * @returns The current focus: `'foreground'` or `'background'`
160
+ */
161
+ currentFocus(): StageFocus;
162
+ /**
163
+ * Returns all actors in the specified focus area.
164
+ *
165
+ * This method is used by the [`Stage`](https://serenity-js.org/api/core/class/Stage/) to retrieve
166
+ * actors for dismissal when scenes or test runs finish.
167
+ *
168
+ * @param focus - The focus area to retrieve actors from
169
+ * @returns An array of actors in the specified focus area
170
+ */
171
+ actorsIn(focus: StageFocus): Actor[];
172
+ /**
173
+ * Clears the spotlight if the current actor is in the specified focus area.
174
+ *
175
+ * This ensures that after actors in a focus area are dismissed, the spotlight
176
+ * doesn't reference a dismissed actor.
177
+ *
178
+ * @param focus - The focus area to check
179
+ */
180
+ clearSpotlightIfIn(focus: StageFocus): void;
181
+ /**
182
+ * Clears all actors from the specified focus area.
183
+ *
184
+ * This method is called by the [`Stage`](https://serenity-js.org/api/core/class/Stage/) after
185
+ * actors have been dismissed to remove them from the internal tracking maps.
186
+ *
187
+ * @param focus - The focus area to clear
188
+ */
189
+ clearActorsIn(focus: StageFocus): void;
190
+ }
191
+ //# sourceMappingURL=ActorLifecycleManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActorLifecycleManager.d.ts","sourceRoot":"","sources":["../../src/stage/ActorLifecycleManager.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,KAAK,EAAgB,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;A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