@serenity-js/core 3.25.0 → 3.25.2
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 +19 -0
- package/README.md +1 -1
- package/lib/Serenity.d.ts +22 -22
- package/lib/Serenity.js +22 -22
- package/lib/adapter/OutputStream.d.ts +5 -4
- package/lib/adapter/OutputStream.d.ts.map +1 -1
- package/lib/adapter/TestRunnerAdapter.d.ts +2 -2
- package/lib/config/ClassDescription.d.ts +1 -1
- package/lib/config/SerenityConfig.d.ts +22 -20
- package/lib/config/SerenityConfig.d.ts.map +1 -1
- package/lib/config/SerenityConfig.js +22 -20
- package/lib/config/SerenityConfig.js.map +1 -1
- package/lib/errors/ErrorFactory.d.ts +2 -1
- package/lib/errors/ErrorFactory.d.ts.map +1 -1
- package/lib/errors/ErrorFactory.js +2 -1
- package/lib/errors/ErrorFactory.js.map +1 -1
- package/lib/errors/RaiseErrors.d.ts +9 -9
- package/lib/errors/RaiseErrors.js +9 -9
- package/lib/errors/diff/AnsiDiffFormatter.d.ts +1 -1
- package/lib/errors/diff/AnsiDiffFormatter.js +1 -1
- package/lib/errors/diff/DiffFormatter.d.ts +1 -1
- package/lib/errors/diff/NoOpDiffFormatter.d.ts +1 -1
- package/lib/errors/diff/NoOpDiffFormatter.js +1 -1
- package/lib/errors/model/AssertionError.d.ts +1 -1
- package/lib/errors/model/AssertionError.js +1 -1
- package/lib/errors/model/ConfigurationError.d.ts +1 -1
- package/lib/errors/model/ConfigurationError.js +1 -1
- package/lib/errors/model/ImplementationPendingError.d.ts +3 -3
- package/lib/errors/model/ImplementationPendingError.js +3 -3
- package/lib/errors/model/ListItemNotFoundError.d.ts +2 -2
- package/lib/errors/model/ListItemNotFoundError.js +2 -2
- package/lib/errors/model/LogicError.d.ts +2 -2
- package/lib/errors/model/LogicError.js +2 -2
- package/lib/errors/model/OperationInterruptedError.d.ts +2 -2
- package/lib/errors/model/OperationInterruptedError.js +2 -2
- package/lib/errors/model/RuntimeError.d.ts +2 -2
- package/lib/errors/model/RuntimeError.js +2 -2
- package/lib/errors/model/TestCompromisedError.d.ts +1 -1
- package/lib/errors/model/TestCompromisedError.js +1 -1
- package/lib/errors/model/TimeoutExpiredError.d.ts +2 -2
- package/lib/errors/model/TimeoutExpiredError.js +2 -2
- package/lib/errors/model/UnknownError.d.ts +1 -1
- package/lib/errors/model/UnknownError.js +1 -1
- package/lib/events/ActivityFinished.d.ts +1 -1
- package/lib/events/ActivityFinished.js +1 -1
- package/lib/events/ActivityStarts.d.ts +1 -1
- package/lib/events/ActivityStarts.js +1 -1
- package/lib/events/BusinessRuleDetected.d.ts +1 -1
- package/lib/events/BusinessRuleDetected.js +1 -1
- package/lib/events/SceneFinishes.d.ts +2 -1
- package/lib/events/SceneFinishes.d.ts.map +1 -1
- package/lib/events/SceneFinishes.js +2 -1
- package/lib/events/SceneFinishes.js.map +1 -1
- package/lib/instance.d.ts +30 -30
- package/lib/instance.js +30 -30
- package/lib/io/format.d.ts +15 -6
- package/lib/io/format.d.ts.map +1 -1
- package/lib/io/format.js +15 -6
- package/lib/io/format.js.map +1 -1
- package/lib/io/loader/ModuleLoader.d.ts +1 -1
- package/lib/io/loader/ModuleLoader.js +1 -1
- package/lib/io/reflection/ValueInspector.d.ts +1 -1
- package/lib/io/reflection/ValueInspector.js +2 -2
- package/lib/io/reflection/ValueInspector.js.map +1 -1
- package/lib/io/stringified.d.ts +1 -1
- package/lib/io/stringified.js +1 -1
- package/lib/io/trimmed.d.ts +1 -1
- package/lib/io/trimmed.js +1 -1
- package/lib/model/artifacts/HTTPRequestResponse.d.ts +2 -2
- package/lib/model/artifacts/HTTPRequestResponse.js +1 -1
- package/lib/screenplay/Activity.d.ts +10 -10
- package/lib/screenplay/Activity.js +5 -5
- package/lib/screenplay/Actor.d.ts +28 -28
- package/lib/screenplay/Actor.js +28 -28
- package/lib/screenplay/Answerable.d.ts +1 -1
- package/lib/screenplay/Answered.d.ts +2 -2
- package/lib/screenplay/Interaction.d.ts +17 -17
- package/lib/screenplay/Interaction.js +12 -12
- package/lib/screenplay/Optional.d.ts +1 -1
- package/lib/screenplay/Question.d.ts +48 -45
- package/lib/screenplay/Question.d.ts.map +1 -1
- package/lib/screenplay/Question.js +39 -36
- package/lib/screenplay/Question.js.map +1 -1
- package/lib/screenplay/RecursivelyAnswered.d.ts +2 -2
- package/lib/screenplay/Task.d.ts +19 -19
- package/lib/screenplay/Task.js +15 -15
- package/lib/screenplay/WithAnswerableProperties.d.ts +2 -2
- package/lib/screenplay/abilities/Ability.d.ts +48 -46
- package/lib/screenplay/abilities/Ability.d.ts.map +1 -1
- package/lib/screenplay/abilities/Ability.js +48 -46
- package/lib/screenplay/abilities/Ability.js.map +1 -1
- package/lib/screenplay/abilities/AbilityType.d.ts +5 -5
- package/lib/screenplay/abilities/AnswerQuestions.d.ts +3 -3
- package/lib/screenplay/abilities/AnswerQuestions.js +3 -3
- package/lib/screenplay/abilities/CanHaveAbilities.d.ts +4 -4
- package/lib/screenplay/abilities/Discardable.d.ts +8 -8
- package/lib/screenplay/abilities/Initialisable.d.ts +11 -11
- package/lib/screenplay/abilities/PerformActivities.d.ts +3 -3
- package/lib/screenplay/abilities/PerformActivities.js +3 -3
- package/lib/screenplay/abilities/UsesAbilities.d.ts +6 -6
- package/lib/screenplay/activities/PerformsActivities.d.ts +7 -7
- package/lib/screenplay/artifacts/CollectsArtifacts.d.ts +4 -5
- package/lib/screenplay/artifacts/CollectsArtifacts.d.ts.map +1 -1
- package/lib/screenplay/debugging/Debug.d.ts +7 -6
- package/lib/screenplay/debugging/Debug.d.ts.map +1 -1
- package/lib/screenplay/debugging/Debug.js +7 -6
- package/lib/screenplay/debugging/Debug.js.map +1 -1
- package/lib/screenplay/debugging/DebuggingResult.d.ts +1 -1
- package/lib/screenplay/debugging/Log.d.ts +7 -5
- package/lib/screenplay/debugging/Log.d.ts.map +1 -1
- package/lib/screenplay/debugging/Log.js +7 -5
- package/lib/screenplay/debugging/Log.js.map +1 -1
- package/lib/screenplay/notes/Notepad.d.ts +13 -13
- package/lib/screenplay/notes/Notepad.js +13 -13
- package/lib/screenplay/notes/NotepadAdapter.d.ts +16 -16
- package/lib/screenplay/notes/NotepadAdapter.js +16 -16
- package/lib/screenplay/notes/TakeNotes.d.ts +9 -9
- package/lib/screenplay/notes/TakeNotes.js +9 -9
- package/lib/screenplay/notes/notes.d.ts +6 -6
- package/lib/screenplay/notes/notes.js +6 -6
- package/lib/screenplay/questions/AnswersQuestions.d.ts +4 -4
- package/lib/screenplay/questions/ChainableMetaQuestion.d.ts +6 -6
- package/lib/screenplay/questions/Check.d.ts +2 -2
- package/lib/screenplay/questions/Check.js +2 -2
- package/lib/screenplay/questions/DescriptionFormattingOptions.d.ts +2 -2
- package/lib/screenplay/questions/Expectation.d.ts +17 -14
- package/lib/screenplay/questions/Expectation.d.ts.map +1 -1
- package/lib/screenplay/questions/Expectation.js +17 -14
- package/lib/screenplay/questions/Expectation.js.map +1 -1
- package/lib/screenplay/questions/List.d.ts +5 -5
- package/lib/screenplay/questions/List.js +5 -5
- package/lib/screenplay/questions/Masked.d.ts +4 -2
- package/lib/screenplay/questions/Masked.d.ts.map +1 -1
- package/lib/screenplay/questions/Masked.js +4 -2
- package/lib/screenplay/questions/Masked.js.map +1 -1
- package/lib/screenplay/questions/MetaQuestion.d.ts +9 -9
- package/lib/screenplay/questions/Unanswered.d.ts +2 -2
- package/lib/screenplay/questions/Unanswered.js +2 -2
- package/lib/screenplay/questions/expectations/ExpectationDetails.d.ts +1 -1
- package/lib/screenplay/questions/expectations/ExpectationDetails.js +1 -1
- package/lib/screenplay/questions/expectations/ExpectationMet.d.ts +1 -1
- package/lib/screenplay/questions/expectations/ExpectationMet.js +1 -1
- package/lib/screenplay/questions/expectations/ExpectationNotMet.d.ts +1 -1
- package/lib/screenplay/questions/expectations/ExpectationNotMet.js +1 -1
- package/lib/screenplay/questions/expectations/ExpectationOutcome.d.ts +2 -2
- package/lib/screenplay/questions/expectations/ExpectationOutcome.js +2 -2
- package/lib/screenplay/questions/tag-functions.d.ts +23 -21
- package/lib/screenplay/questions/tag-functions.d.ts.map +1 -1
- package/lib/screenplay/questions/tag-functions.js +5 -5
- package/lib/screenplay/questions/tag-functions.js.map +1 -1
- package/lib/screenplay/time/TellsTime.d.ts +4 -4
- package/lib/screenplay/time/abilities/ScheduleWork.d.ts +2 -2
- package/lib/screenplay/time/abilities/ScheduleWork.js +2 -2
- package/lib/screenplay/time/activities/Wait.d.ts +29 -27
- package/lib/screenplay/time/activities/Wait.d.ts.map +1 -1
- package/lib/screenplay/time/activities/Wait.js +29 -27
- package/lib/screenplay/time/activities/Wait.js.map +1 -1
- package/lib/screenplay/time/models/Clock.d.ts +4 -4
- package/lib/screenplay/time/models/Clock.js +4 -4
- package/lib/screenplay/time/models/Duration.d.ts +1 -1
- package/lib/screenplay/time/models/Duration.js +1 -1
- package/lib/screenplay/time/models/Timestamp.d.ts +2 -2
- package/lib/screenplay/time/models/Timestamp.js +2 -2
- package/lib/stage/Cast.d.ts +21 -21
- package/lib/stage/Cast.js +19 -19
- package/lib/stage/Extras.d.ts +1 -1
- package/lib/stage/Extras.js +1 -1
- package/lib/stage/ListensToDomainEvents.d.ts +7 -7
- package/lib/stage/Stage.d.ts +30 -30
- package/lib/stage/Stage.d.ts.map +1 -1
- package/lib/stage/Stage.js +30 -30
- package/lib/stage/Stage.js.map +1 -1
- package/lib/stage/StageCrewMember.d.ts +11 -11
- package/lib/stage/StageCrewMemberBuilder.d.ts +7 -7
- package/lib/stage/StageCrewMemberBuilderDependencies.d.ts +2 -2
- package/lib/stage/crew/artifact-archiver/ArtifactArchiver.d.ts +4 -4
- package/lib/stage/crew/artifact-archiver/ArtifactArchiver.js +4 -4
- package/lib/stage/crew/stream-reporter/StreamReporter.d.ts +7 -7
- package/lib/stage/crew/stream-reporter/StreamReporter.js +7 -7
- package/package.json +4 -4
- package/src/Serenity.ts +22 -22
- package/src/adapter/OutputStream.ts +5 -4
- package/src/adapter/TestRunnerAdapter.ts +2 -2
- package/src/config/ClassDescription.ts +1 -1
- package/src/config/SerenityConfig.ts +22 -20
- package/src/errors/ErrorFactory.ts +2 -1
- package/src/errors/ErrorSerialiser.ts +3 -3
- package/src/errors/RaiseErrors.ts +9 -9
- package/src/errors/diff/AnsiDiffFormatter.ts +1 -1
- package/src/errors/diff/DiffFormatter.ts +1 -1
- package/src/errors/diff/NoOpDiffFormatter.ts +1 -1
- package/src/errors/model/AssertionError.ts +1 -1
- package/src/errors/model/ConfigurationError.ts +1 -1
- package/src/errors/model/ImplementationPendingError.ts +3 -3
- package/src/errors/model/ListItemNotFoundError.ts +2 -2
- package/src/errors/model/LogicError.ts +2 -2
- package/src/errors/model/OperationInterruptedError.ts +2 -2
- package/src/errors/model/RuntimeError.ts +2 -2
- package/src/errors/model/TestCompromisedError.ts +1 -1
- package/src/errors/model/TimeoutExpiredError.ts +2 -2
- package/src/errors/model/UnknownError.ts +1 -1
- package/src/events/ActivityFinished.ts +1 -1
- package/src/events/ActivityStarts.ts +1 -1
- package/src/events/BusinessRuleDetected.ts +1 -1
- package/src/events/SceneFinishes.ts +2 -1
- package/src/instance.ts +30 -30
- package/src/io/format.ts +15 -6
- package/src/io/loader/ModuleLoader.ts +1 -1
- package/src/io/reflection/ValueInspector.ts +3 -3
- package/src/io/stringified.ts +1 -1
- package/src/io/trimmed.ts +1 -1
- package/src/model/artifacts/HTTPRequestResponse.ts +2 -2
- package/src/screenplay/Activity.ts +10 -10
- package/src/screenplay/Actor.ts +28 -28
- package/src/screenplay/Answerable.ts +1 -1
- package/src/screenplay/Answered.ts +2 -2
- package/src/screenplay/Interaction.ts +17 -17
- package/src/screenplay/Optional.ts +1 -1
- package/src/screenplay/Question.ts +48 -45
- package/src/screenplay/RecursivelyAnswered.ts +2 -2
- package/src/screenplay/Task.ts +19 -19
- package/src/screenplay/WithAnswerableProperties.ts +2 -2
- package/src/screenplay/abilities/Ability.ts +48 -46
- package/src/screenplay/abilities/AbilityType.ts +5 -5
- package/src/screenplay/abilities/AnswerQuestions.ts +3 -3
- package/src/screenplay/abilities/CanHaveAbilities.ts +4 -4
- package/src/screenplay/abilities/Discardable.ts +8 -8
- package/src/screenplay/abilities/Initialisable.ts +11 -11
- package/src/screenplay/abilities/PerformActivities.ts +3 -3
- package/src/screenplay/abilities/UsesAbilities.ts +6 -6
- package/src/screenplay/activities/PerformsActivities.ts +7 -7
- package/src/screenplay/artifacts/CollectsArtifacts.ts +4 -5
- package/src/screenplay/debugging/Debug.ts +7 -6
- package/src/screenplay/debugging/DebuggingResult.ts +1 -1
- package/src/screenplay/debugging/Log.ts +7 -5
- package/src/screenplay/notes/Notepad.ts +13 -13
- package/src/screenplay/notes/NotepadAdapter.ts +16 -16
- package/src/screenplay/notes/TakeNotes.ts +9 -9
- package/src/screenplay/notes/notes.ts +6 -6
- package/src/screenplay/questions/AnswersQuestions.ts +4 -4
- package/src/screenplay/questions/ChainableMetaQuestion.ts +6 -6
- package/src/screenplay/questions/Check.ts +2 -2
- package/src/screenplay/questions/DescriptionFormattingOptions.ts +2 -2
- package/src/screenplay/questions/Expectation.ts +17 -14
- package/src/screenplay/questions/List.ts +5 -5
- package/src/screenplay/questions/Masked.ts +4 -2
- package/src/screenplay/questions/MetaQuestion.ts +9 -9
- package/src/screenplay/questions/Unanswered.ts +2 -2
- package/src/screenplay/questions/expectations/ExpectationDetails.ts +1 -1
- package/src/screenplay/questions/expectations/ExpectationMet.ts +1 -1
- package/src/screenplay/questions/expectations/ExpectationNotMet.ts +1 -1
- package/src/screenplay/questions/expectations/ExpectationOutcome.ts +2 -2
- package/src/screenplay/questions/tag-functions.ts +23 -21
- package/src/screenplay/time/TellsTime.ts +4 -4
- package/src/screenplay/time/abilities/ScheduleWork.ts +2 -2
- package/src/screenplay/time/activities/Wait.ts +29 -27
- package/src/screenplay/time/models/Clock.ts +4 -4
- package/src/screenplay/time/models/Duration.ts +1 -1
- package/src/screenplay/time/models/Timestamp.ts +2 -2
- package/src/stage/Cast.ts +21 -21
- package/src/stage/Extras.ts +1 -1
- package/src/stage/ListensToDomainEvents.ts +7 -7
- package/src/stage/Stage.ts +30 -30
- package/src/stage/StageCrewMember.ts +11 -11
- package/src/stage/StageCrewMemberBuilder.ts +7 -7
- package/src/stage/StageCrewMemberBuilderDependencies.ts +2 -2
- package/src/stage/crew/artifact-archiver/ArtifactArchiver.ts +4 -4
- package/src/stage/crew/stream-reporter/StreamReporter.ts +7 -7
|
@@ -1,37 +1,38 @@
|
|
|
1
1
|
import type { AbilityType } from './AbilityType';
|
|
2
2
|
import type { UsesAbilities } from './UsesAbilities';
|
|
3
3
|
/**
|
|
4
|
-
* **Abilities** enable
|
|
5
|
-
* to perform
|
|
6
|
-
* and answer
|
|
4
|
+
* **Abilities** enable [actors](https://serenity-js.org/api/core/class/Actor/)
|
|
5
|
+
* to perform [interactions](https://serenity-js.org/api/core/class/Interaction/) with the system under test
|
|
6
|
+
* and answer [questions](https://serenity-js.org/api/core/class/Question/) about its state.
|
|
7
7
|
*
|
|
8
8
|
* From the technical perspective, **abilities** act as **wrappers** around any **integration libraries** required
|
|
9
9
|
* to communicate with the external interfaces of system under test,
|
|
10
|
-
* such as
|
|
11
|
-
* They also enable [portability](/handbook/design/portable-test-code)
|
|
10
|
+
* such as [web browser drivers](https://serenity-js.org/api/web/class/BrowseTheWeb/) or an [HTTP client](https://serenity-js.org/api/rest/class/CallAnApi/).
|
|
11
|
+
* They also enable [portability](https://serenity-js.org/handbook/design/portable-test-code)
|
|
12
12
|
* of your test code across such integration libraries.
|
|
13
13
|
*
|
|
14
|
-
* Abilities are the core building block of the [Screenplay Pattern](/handbook/design/screenplay-pattern),
|
|
15
|
-
* along with
|
|
14
|
+
* Abilities are the core building block of the [Screenplay Pattern](https://serenity-js.org/handbook/design/screenplay-pattern),
|
|
15
|
+
* along with [actors](https://serenity-js.org/api/core/class/Actor/), [interactions](https://serenity-js.org/api/core/class/Interaction/),
|
|
16
|
+
* [questions](https://serenity-js.org/api/core/class/Question/), and [tasks](https://serenity-js.org/api/core/class/Task/).
|
|
16
17
|
*
|
|
17
|
-
* 
|
|
18
|
+
* 
|
|
18
19
|
*
|
|
19
20
|
* Learn more about:
|
|
20
|
-
* -
|
|
21
|
-
* -
|
|
22
|
-
* -
|
|
23
|
-
* -
|
|
24
|
-
* - [Web testing](/handbook/web-testing/)
|
|
25
|
-
* - [API testing](/handbook/api-testing/)
|
|
26
|
-
* - [Mobile testing](/handbook/mobile-testing/)
|
|
21
|
+
* - [Actors](https://serenity-js.org/api/core/class/Actor/)
|
|
22
|
+
* - [Configuring actors using Casts](https://serenity-js.org/api/core/class/Cast/)
|
|
23
|
+
* - [Interactions](https://serenity-js.org/api/core/class/Interaction/)
|
|
24
|
+
* - [Questions](https://serenity-js.org/api/core/class/Question/)
|
|
25
|
+
* - [Web testing](https://serenity-js.org/handbook/web-testing/)
|
|
26
|
+
* - [API testing](https://serenity-js.org/handbook/api-testing/)
|
|
27
|
+
* - [Mobile testing](https://serenity-js.org/handbook/mobile-testing/)
|
|
27
28
|
*
|
|
28
29
|
* ## Giving actors the abilities to interact
|
|
29
30
|
*
|
|
30
31
|
* Serenity/JS actors are capable of interacting with **any interface** of the system under test,
|
|
31
|
-
* be it a [web UI](/handbook/web-testing/), a [mobile app](/handbook/mobile-testing/), a [web service](/handbook/api-testing/),
|
|
32
|
-
* or
|
|
32
|
+
* be it a [web UI](https://serenity-js.org/handbook/web-testing/), a [mobile app](https://serenity-js.org/handbook/mobile-testing/), a [web service](https://serenity-js.org/handbook/api-testing/),
|
|
33
|
+
* or [anything else](https://serenity-js.org/api/core/class/Ability/) that a Node.js program can talk to.
|
|
33
34
|
* This flexibility is enabled by a mechanism called _**abilities**_
|
|
34
|
-
* and achieved without introducing any unnecessary dependencies to your code base thanks to the [modular architecture](/handbook/
|
|
35
|
+
* and achieved without introducing any unnecessary dependencies to your code base thanks to the [modular architecture](https://serenity-js.org/handbook/getting-started/architecture) of Serenity/JS.
|
|
35
36
|
*
|
|
36
37
|
* :::tip Remember
|
|
37
38
|
* **Actors** have **abilities** that enable them to **perform interactions** and **answer questions**.
|
|
@@ -40,18 +41,18 @@ import type { UsesAbilities } from './UsesAbilities';
|
|
|
40
41
|
* From the technical perspective, an **ability** is an [adapter](https://en.wikipedia.org/wiki/Adapter_pattern)
|
|
41
42
|
* around an interface-specific integration library, such as a web browser driver, an HTTP client, a database client, and so on.
|
|
42
43
|
* You give an actor an ability, and it's the ability's responsibility to provide a consistent API around the integration library and deal with any of its quirks.
|
|
43
|
-
* Abilities **encapsulate integration libraries** and handle their
|
|
44
|
-
* the process of
|
|
44
|
+
* Abilities **encapsulate integration libraries** and handle their [configuration and initialisation](https://serenity-js.org/api/core/interface/Initialisable/),
|
|
45
|
+
* the process of [freeing up any resources](https://serenity-js.org/api/core/interface/Discardable/) they hold,
|
|
45
46
|
* as well as managing any state associated with the library.
|
|
46
47
|
*
|
|
47
48
|
* ### Portable interactions with web interfaces
|
|
48
49
|
*
|
|
49
50
|
* To make your Serenity/JS actors interact with web interfaces,
|
|
50
|
-
* you call the [`Actor.whoCan`](/api/core/class/Actor#whoCan) method and give them an implementation of the ability to [`BrowseTheWeb`](/api/web/class/BrowseTheWeb),
|
|
51
|
+
* you call the [`Actor.whoCan`](https://serenity-js.org/api/core/class/Actor#whoCan) method and give them an implementation of the ability to [`BrowseTheWeb`](https://serenity-js.org/api/web/class/BrowseTheWeb),
|
|
51
52
|
* specific to your web integration tool of choice.
|
|
52
53
|
*
|
|
53
|
-
* Note how
|
|
54
|
-
* all **extend** the base ability to
|
|
54
|
+
* Note how [`BrowseTheWebWithPlaywright`](https://serenity-js.org/api/playwright/class/BrowseTheWebWithPlaywright/), [`BrowseTheWebWithWebdriverIO`](https://serenity-js.org/api/webdriverio/class/BrowseTheWebWithWebdriverIO/), and [`BrowseTheWebWithProtractor`](https://serenity-js.org/api/protractor/class/BrowseTheWebWithProtractor/)
|
|
55
|
+
* all **extend** the base ability to [`BrowseTheWeb`](https://serenity-js.org/api/web/class/BrowseTheWeb/).
|
|
55
56
|
*
|
|
56
57
|
* #### Playwright
|
|
57
58
|
*
|
|
@@ -89,10 +90,10 @@ import type { UsesAbilities } from './UsesAbilities';
|
|
|
89
90
|
*
|
|
90
91
|
* ### Retrieving an ability
|
|
91
92
|
*
|
|
92
|
-
* Use
|
|
93
|
+
* Use [`PerformActivities`](https://serenity-js.org/api/core/class/PerformActivities/)} to retrieve an ability in a custom [`Interaction`](https://serenity-js.org/api/core/class/Interaction/) or [`Question`](https://serenity-js.org/api/core/class/Question/) implementation.
|
|
93
94
|
*
|
|
94
|
-
* Here, `Ability` can be the integration library-specific class, for example
|
|
95
|
-
* or its library-agnostic parent class, like
|
|
95
|
+
* Here, `Ability` can be the integration library-specific class, for example [`BrowseTheWebWithPlaywright`](https://serenity-js.org/api/playwright/class/BrowseTheWebWithPlaywright/),
|
|
96
|
+
* or its library-agnostic parent class, like [`BrowseTheWeb`](https://serenity-js.org/api/web/class/BrowseTheWeb/).
|
|
96
97
|
*
|
|
97
98
|
* To make your code portable across the various integration libraries, retrieve the ability
|
|
98
99
|
* using the library-agnostic parent class:
|
|
@@ -109,15 +110,15 @@ import type { UsesAbilities } from './UsesAbilities';
|
|
|
109
110
|
*
|
|
110
111
|
* Another reason is that the Serenity/JS implementation of the Screenplay Pattern lets you **completely decouple the actor from the integration libraries**
|
|
111
112
|
* and make the abilities of the same type **interchangeable**.
|
|
112
|
-
* For example, [Serenity/JS web modules](/handbook/web-testing/serenity-js-web-modules) offer an abstraction that lets you switch between web integration libraries
|
|
113
|
+
* For example, [Serenity/JS web modules](https://serenity-js.org/handbook/web-testing/serenity-js-web-modules) offer an abstraction that lets you switch between web integration libraries
|
|
113
114
|
* as vastly different as Selenium, WebdriverIO, or Playwright without having to change _anything whatsoever_ in your test scenarios.
|
|
114
115
|
*
|
|
115
|
-
* What this means is that your test code can become [portable and reusable across projects and teams](/handbook/design/portable-test-code),
|
|
116
|
+
* What this means is that your test code can become [portable and reusable across projects and teams](https://serenity-js.org/handbook/design/portable-test-code),
|
|
116
117
|
* even if they don't use the same low-level integration tools. It also helps you to **avoid vendor lock-in**, as you can wrap any third-party integration library
|
|
117
118
|
* into an ability and swap it out for another implementation if you need to.
|
|
118
119
|
*
|
|
119
120
|
* However, Serenity/JS **doesn't prevent you** from using the integration libraries directly.
|
|
120
|
-
* When you need to, you can use a library-specific ability like
|
|
121
|
+
* When you need to, you can use a library-specific ability like [`BrowseTheWebWithPlaywright`](https://serenity-js.org/api/playwright/class/BrowseTheWebWithPlaywright/)
|
|
121
122
|
* to trade portability for access to library-specific low-level methods:
|
|
122
123
|
*
|
|
123
124
|
* ```typescript
|
|
@@ -140,7 +141,7 @@ import type { UsesAbilities } from './UsesAbilities';
|
|
|
140
141
|
* ## Associating actors with data
|
|
141
142
|
*
|
|
142
143
|
* One more reason to use abilities is that abilities can also help you to **associate actors with data** they need to perform their activities.
|
|
143
|
-
* For example, a commonly used ability is one to [`TakeNotes`](/api/core/class/TakeNotes), which allows your actors to start the test scenario
|
|
144
|
+
* For example, a commonly used ability is one to [`TakeNotes`](https://serenity-js.org/api/core/class/TakeNotes), which allows your actors to start the test scenario
|
|
144
145
|
* equipped with some data set, or record information about what they see in the test scenario so that they can act upon it later:
|
|
145
146
|
*
|
|
146
147
|
* ```typescript
|
|
@@ -165,7 +166,7 @@ import type { UsesAbilities } from './UsesAbilities';
|
|
|
165
166
|
* ## Actors with multiple abilities
|
|
166
167
|
*
|
|
167
168
|
* Of course, an actor can have **any number of abilities** they need to play their role.
|
|
168
|
-
* For example, it is quite common for an actor to be able to [`BrowseTheWeb`](/api/web/class/BrowseTheWeb), [`TakeNotes`](/api/core/class/TakeNotes), and [`CallAnApi`](/api/rest/class/CallAnApi):
|
|
169
|
+
* For example, it is quite common for an actor to be able to [`BrowseTheWeb`](https://serenity-js.org/api/web/class/BrowseTheWeb), [`TakeNotes`](https://serenity-js.org/api/core/class/TakeNotes), and [`CallAnApi`](https://serenity-js.org/api/rest/class/CallAnApi):
|
|
169
170
|
*
|
|
170
171
|
* ```typescript
|
|
171
172
|
* import { actorCalled, Notepad, TakeNotes } from '@serenity-js/core'
|
|
@@ -197,17 +198,17 @@ import type { UsesAbilities } from './UsesAbilities';
|
|
|
197
198
|
* ## Writing custom abilities
|
|
198
199
|
*
|
|
199
200
|
* If your system under test provides a type of interface that Serenity/JS doesn't support yet,
|
|
200
|
-
* you might want to implement a custom
|
|
201
|
-
* and
|
|
201
|
+
* you might want to implement a custom [`Ability`](https://serenity-js.org/api/core/class/Ability/), as well as [interactions](https://serenity-js.org/api/core/class/Interaction/)
|
|
202
|
+
* and [questions](https://serenity-js.org/api/core/class/Question/) to interact with it.
|
|
202
203
|
*
|
|
203
|
-
* The best way to start with that is for you to review the examples in the
|
|
204
|
+
* The best way to start with that is for you to review the examples in the [Screenplay Pattern API docs](https://serenity-js.org/api/core/class/Ability/),
|
|
204
205
|
* as well as the [Serenity/JS code base on GitHub](https://github.com/serenity-js/serenity-js/tree/main/packages).
|
|
205
|
-
* Also note that all the [Serenity/JS modules](/handbook/
|
|
206
|
+
* Also note that all the [Serenity/JS modules](https://serenity-js.org/handbook/getting-started/architecture)
|
|
206
207
|
* have their automated tests written in such a way to not only provide an **extremely high test coverage** for the framework itself,
|
|
207
208
|
* but to be **accessible** and act as a **reference implementation for you** to create your own integrations.
|
|
208
209
|
*
|
|
209
210
|
* If you believe that the custom integration you've developed could benefit the wider Serenity/JS community,
|
|
210
|
-
* please consider open-sourcing it yourself, or [contributing it](/contributing) to the main framework.
|
|
211
|
+
* please consider open-sourcing it yourself, or [contributing it](https://serenity-js.org/community/contributing/) to the main framework.
|
|
211
212
|
*
|
|
212
213
|
* [](https://matrix.to/#/#serenity-js:gitter.im)
|
|
213
214
|
*
|
|
@@ -265,8 +266,9 @@ import type { UsesAbilities } from './UsesAbilities';
|
|
|
265
266
|
* ## Using auto-initialisable and auto-discardable abilities
|
|
266
267
|
*
|
|
267
268
|
* Abilities that rely on resources that need to be initialised before they can be used,
|
|
268
|
-
* or discarded before the actor is dismissed can implement
|
|
269
|
-
*
|
|
269
|
+
* or discarded before the actor is dismissed can implement
|
|
270
|
+
* the [`Initialisable`](https://serenity-js.org/api/core/interface/Initialisable/)
|
|
271
|
+
* or [`Discardable`](https://serenity-js.org/api/core/interface/Discardable/) interfaces, respectively.
|
|
270
272
|
*
|
|
271
273
|
* ### Defining a custom ability to `QueryPostgresDB`
|
|
272
274
|
*
|
|
@@ -347,19 +349,19 @@ import type { UsesAbilities } from './UsesAbilities';
|
|
|
347
349
|
* ```
|
|
348
350
|
*
|
|
349
351
|
* ## Learn more
|
|
350
|
-
* -
|
|
351
|
-
* -
|
|
352
|
-
* -
|
|
353
|
-
* -
|
|
354
|
-
* -
|
|
355
|
-
* -
|
|
352
|
+
* - [`AbilityType`](https://serenity-js.org/api/core/#AbilityType)
|
|
353
|
+
* - [`Initialisable`](https://serenity-js.org/api/core/interface/Initialisable/)
|
|
354
|
+
* - [`Discardable`](https://serenity-js.org/api/core/interface/Discardable/)
|
|
355
|
+
* - [`BrowseTheWeb`](https://serenity-js.org/api/web/class/BrowseTheWeb/)
|
|
356
|
+
* - [`CallAnApi`](https://serenity-js.org/api/rest/class/CallAnApi/)
|
|
357
|
+
* - [`TakeNotes`](https://serenity-js.org/api/core/class/TakeNotes/)
|
|
356
358
|
*
|
|
357
359
|
* @group Screenplay Pattern
|
|
358
360
|
*/
|
|
359
361
|
export declare abstract class Ability {
|
|
360
362
|
/**
|
|
361
|
-
* Used to access an
|
|
362
|
-
* from within the
|
|
363
|
+
* Used to access an [actor's](https://serenity-js.org/api/core/class/Actor/) [ability](https://serenity-js.org/api/core/class/Ability/) of the given type
|
|
364
|
+
* from within the [`Interaction`](https://serenity-js.org/api/core/class/Interaction/) and [`Question`](https://serenity-js.org/api/core/class/Question/) classes.
|
|
363
365
|
*
|
|
364
366
|
* #### Retrieving an ability in an interaction definition
|
|
365
367
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Ability.d.ts","sourceRoot":"","sources":["../../../src/screenplay/abilities/Ability.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD
|
|
1
|
+
{"version":3,"file":"Ability.d.ts","sourceRoot":"","sources":["../../../src/screenplay/abilities/Ability.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqWG;AACH,8BAAsB,OAAO;IAEzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoCG;IACH,MAAM,CAAC,EAAE,CAAC,CAAC,SAAS,OAAO,EACvB,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,EACpB,KAAK,EAAE,aAAa,GACrB,CAAC;CAGP"}
|
|
@@ -2,37 +2,38 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Ability = void 0;
|
|
4
4
|
/**
|
|
5
|
-
* **Abilities** enable
|
|
6
|
-
* to perform
|
|
7
|
-
* and answer
|
|
5
|
+
* **Abilities** enable [actors](https://serenity-js.org/api/core/class/Actor/)
|
|
6
|
+
* to perform [interactions](https://serenity-js.org/api/core/class/Interaction/) with the system under test
|
|
7
|
+
* and answer [questions](https://serenity-js.org/api/core/class/Question/) about its state.
|
|
8
8
|
*
|
|
9
9
|
* From the technical perspective, **abilities** act as **wrappers** around any **integration libraries** required
|
|
10
10
|
* to communicate with the external interfaces of system under test,
|
|
11
|
-
* such as
|
|
12
|
-
* They also enable [portability](/handbook/design/portable-test-code)
|
|
11
|
+
* such as [web browser drivers](https://serenity-js.org/api/web/class/BrowseTheWeb/) or an [HTTP client](https://serenity-js.org/api/rest/class/CallAnApi/).
|
|
12
|
+
* They also enable [portability](https://serenity-js.org/handbook/design/portable-test-code)
|
|
13
13
|
* of your test code across such integration libraries.
|
|
14
14
|
*
|
|
15
|
-
* Abilities are the core building block of the [Screenplay Pattern](/handbook/design/screenplay-pattern),
|
|
16
|
-
* along with
|
|
15
|
+
* Abilities are the core building block of the [Screenplay Pattern](https://serenity-js.org/handbook/design/screenplay-pattern),
|
|
16
|
+
* along with [actors](https://serenity-js.org/api/core/class/Actor/), [interactions](https://serenity-js.org/api/core/class/Interaction/),
|
|
17
|
+
* [questions](https://serenity-js.org/api/core/class/Question/), and [tasks](https://serenity-js.org/api/core/class/Task/).
|
|
17
18
|
*
|
|
18
|
-
* 
|
|
19
|
+
* 
|
|
19
20
|
*
|
|
20
21
|
* Learn more about:
|
|
21
|
-
* -
|
|
22
|
-
* -
|
|
23
|
-
* -
|
|
24
|
-
* -
|
|
25
|
-
* - [Web testing](/handbook/web-testing/)
|
|
26
|
-
* - [API testing](/handbook/api-testing/)
|
|
27
|
-
* - [Mobile testing](/handbook/mobile-testing/)
|
|
22
|
+
* - [Actors](https://serenity-js.org/api/core/class/Actor/)
|
|
23
|
+
* - [Configuring actors using Casts](https://serenity-js.org/api/core/class/Cast/)
|
|
24
|
+
* - [Interactions](https://serenity-js.org/api/core/class/Interaction/)
|
|
25
|
+
* - [Questions](https://serenity-js.org/api/core/class/Question/)
|
|
26
|
+
* - [Web testing](https://serenity-js.org/handbook/web-testing/)
|
|
27
|
+
* - [API testing](https://serenity-js.org/handbook/api-testing/)
|
|
28
|
+
* - [Mobile testing](https://serenity-js.org/handbook/mobile-testing/)
|
|
28
29
|
*
|
|
29
30
|
* ## Giving actors the abilities to interact
|
|
30
31
|
*
|
|
31
32
|
* Serenity/JS actors are capable of interacting with **any interface** of the system under test,
|
|
32
|
-
* be it a [web UI](/handbook/web-testing/), a [mobile app](/handbook/mobile-testing/), a [web service](/handbook/api-testing/),
|
|
33
|
-
* or
|
|
33
|
+
* be it a [web UI](https://serenity-js.org/handbook/web-testing/), a [mobile app](https://serenity-js.org/handbook/mobile-testing/), a [web service](https://serenity-js.org/handbook/api-testing/),
|
|
34
|
+
* or [anything else](https://serenity-js.org/api/core/class/Ability/) that a Node.js program can talk to.
|
|
34
35
|
* This flexibility is enabled by a mechanism called _**abilities**_
|
|
35
|
-
* and achieved without introducing any unnecessary dependencies to your code base thanks to the [modular architecture](/handbook/
|
|
36
|
+
* and achieved without introducing any unnecessary dependencies to your code base thanks to the [modular architecture](https://serenity-js.org/handbook/getting-started/architecture) of Serenity/JS.
|
|
36
37
|
*
|
|
37
38
|
* :::tip Remember
|
|
38
39
|
* **Actors** have **abilities** that enable them to **perform interactions** and **answer questions**.
|
|
@@ -41,18 +42,18 @@ exports.Ability = void 0;
|
|
|
41
42
|
* From the technical perspective, an **ability** is an [adapter](https://en.wikipedia.org/wiki/Adapter_pattern)
|
|
42
43
|
* around an interface-specific integration library, such as a web browser driver, an HTTP client, a database client, and so on.
|
|
43
44
|
* You give an actor an ability, and it's the ability's responsibility to provide a consistent API around the integration library and deal with any of its quirks.
|
|
44
|
-
* Abilities **encapsulate integration libraries** and handle their
|
|
45
|
-
* the process of
|
|
45
|
+
* Abilities **encapsulate integration libraries** and handle their [configuration and initialisation](https://serenity-js.org/api/core/interface/Initialisable/),
|
|
46
|
+
* the process of [freeing up any resources](https://serenity-js.org/api/core/interface/Discardable/) they hold,
|
|
46
47
|
* as well as managing any state associated with the library.
|
|
47
48
|
*
|
|
48
49
|
* ### Portable interactions with web interfaces
|
|
49
50
|
*
|
|
50
51
|
* To make your Serenity/JS actors interact with web interfaces,
|
|
51
|
-
* you call the [`Actor.whoCan`](/api/core/class/Actor#whoCan) method and give them an implementation of the ability to [`BrowseTheWeb`](/api/web/class/BrowseTheWeb),
|
|
52
|
+
* you call the [`Actor.whoCan`](https://serenity-js.org/api/core/class/Actor#whoCan) method and give them an implementation of the ability to [`BrowseTheWeb`](https://serenity-js.org/api/web/class/BrowseTheWeb),
|
|
52
53
|
* specific to your web integration tool of choice.
|
|
53
54
|
*
|
|
54
|
-
* Note how
|
|
55
|
-
* all **extend** the base ability to
|
|
55
|
+
* Note how [`BrowseTheWebWithPlaywright`](https://serenity-js.org/api/playwright/class/BrowseTheWebWithPlaywright/), [`BrowseTheWebWithWebdriverIO`](https://serenity-js.org/api/webdriverio/class/BrowseTheWebWithWebdriverIO/), and [`BrowseTheWebWithProtractor`](https://serenity-js.org/api/protractor/class/BrowseTheWebWithProtractor/)
|
|
56
|
+
* all **extend** the base ability to [`BrowseTheWeb`](https://serenity-js.org/api/web/class/BrowseTheWeb/).
|
|
56
57
|
*
|
|
57
58
|
* #### Playwright
|
|
58
59
|
*
|
|
@@ -90,10 +91,10 @@ exports.Ability = void 0;
|
|
|
90
91
|
*
|
|
91
92
|
* ### Retrieving an ability
|
|
92
93
|
*
|
|
93
|
-
* Use
|
|
94
|
+
* Use [`PerformActivities`](https://serenity-js.org/api/core/class/PerformActivities/)} to retrieve an ability in a custom [`Interaction`](https://serenity-js.org/api/core/class/Interaction/) or [`Question`](https://serenity-js.org/api/core/class/Question/) implementation.
|
|
94
95
|
*
|
|
95
|
-
* Here, `Ability` can be the integration library-specific class, for example
|
|
96
|
-
* or its library-agnostic parent class, like
|
|
96
|
+
* Here, `Ability` can be the integration library-specific class, for example [`BrowseTheWebWithPlaywright`](https://serenity-js.org/api/playwright/class/BrowseTheWebWithPlaywright/),
|
|
97
|
+
* or its library-agnostic parent class, like [`BrowseTheWeb`](https://serenity-js.org/api/web/class/BrowseTheWeb/).
|
|
97
98
|
*
|
|
98
99
|
* To make your code portable across the various integration libraries, retrieve the ability
|
|
99
100
|
* using the library-agnostic parent class:
|
|
@@ -110,15 +111,15 @@ exports.Ability = void 0;
|
|
|
110
111
|
*
|
|
111
112
|
* Another reason is that the Serenity/JS implementation of the Screenplay Pattern lets you **completely decouple the actor from the integration libraries**
|
|
112
113
|
* and make the abilities of the same type **interchangeable**.
|
|
113
|
-
* For example, [Serenity/JS web modules](/handbook/web-testing/serenity-js-web-modules) offer an abstraction that lets you switch between web integration libraries
|
|
114
|
+
* For example, [Serenity/JS web modules](https://serenity-js.org/handbook/web-testing/serenity-js-web-modules) offer an abstraction that lets you switch between web integration libraries
|
|
114
115
|
* as vastly different as Selenium, WebdriverIO, or Playwright without having to change _anything whatsoever_ in your test scenarios.
|
|
115
116
|
*
|
|
116
|
-
* What this means is that your test code can become [portable and reusable across projects and teams](/handbook/design/portable-test-code),
|
|
117
|
+
* What this means is that your test code can become [portable and reusable across projects and teams](https://serenity-js.org/handbook/design/portable-test-code),
|
|
117
118
|
* even if they don't use the same low-level integration tools. It also helps you to **avoid vendor lock-in**, as you can wrap any third-party integration library
|
|
118
119
|
* into an ability and swap it out for another implementation if you need to.
|
|
119
120
|
*
|
|
120
121
|
* However, Serenity/JS **doesn't prevent you** from using the integration libraries directly.
|
|
121
|
-
* When you need to, you can use a library-specific ability like
|
|
122
|
+
* When you need to, you can use a library-specific ability like [`BrowseTheWebWithPlaywright`](https://serenity-js.org/api/playwright/class/BrowseTheWebWithPlaywright/)
|
|
122
123
|
* to trade portability for access to library-specific low-level methods:
|
|
123
124
|
*
|
|
124
125
|
* ```typescript
|
|
@@ -141,7 +142,7 @@ exports.Ability = void 0;
|
|
|
141
142
|
* ## Associating actors with data
|
|
142
143
|
*
|
|
143
144
|
* One more reason to use abilities is that abilities can also help you to **associate actors with data** they need to perform their activities.
|
|
144
|
-
* For example, a commonly used ability is one to [`TakeNotes`](/api/core/class/TakeNotes), which allows your actors to start the test scenario
|
|
145
|
+
* For example, a commonly used ability is one to [`TakeNotes`](https://serenity-js.org/api/core/class/TakeNotes), which allows your actors to start the test scenario
|
|
145
146
|
* equipped with some data set, or record information about what they see in the test scenario so that they can act upon it later:
|
|
146
147
|
*
|
|
147
148
|
* ```typescript
|
|
@@ -166,7 +167,7 @@ exports.Ability = void 0;
|
|
|
166
167
|
* ## Actors with multiple abilities
|
|
167
168
|
*
|
|
168
169
|
* Of course, an actor can have **any number of abilities** they need to play their role.
|
|
169
|
-
* For example, it is quite common for an actor to be able to [`BrowseTheWeb`](/api/web/class/BrowseTheWeb), [`TakeNotes`](/api/core/class/TakeNotes), and [`CallAnApi`](/api/rest/class/CallAnApi):
|
|
170
|
+
* For example, it is quite common for an actor to be able to [`BrowseTheWeb`](https://serenity-js.org/api/web/class/BrowseTheWeb), [`TakeNotes`](https://serenity-js.org/api/core/class/TakeNotes), and [`CallAnApi`](https://serenity-js.org/api/rest/class/CallAnApi):
|
|
170
171
|
*
|
|
171
172
|
* ```typescript
|
|
172
173
|
* import { actorCalled, Notepad, TakeNotes } from '@serenity-js/core'
|
|
@@ -198,17 +199,17 @@ exports.Ability = void 0;
|
|
|
198
199
|
* ## Writing custom abilities
|
|
199
200
|
*
|
|
200
201
|
* If your system under test provides a type of interface that Serenity/JS doesn't support yet,
|
|
201
|
-
* you might want to implement a custom
|
|
202
|
-
* and
|
|
202
|
+
* you might want to implement a custom [`Ability`](https://serenity-js.org/api/core/class/Ability/), as well as [interactions](https://serenity-js.org/api/core/class/Interaction/)
|
|
203
|
+
* and [questions](https://serenity-js.org/api/core/class/Question/) to interact with it.
|
|
203
204
|
*
|
|
204
|
-
* The best way to start with that is for you to review the examples in the
|
|
205
|
+
* The best way to start with that is for you to review the examples in the [Screenplay Pattern API docs](https://serenity-js.org/api/core/class/Ability/),
|
|
205
206
|
* as well as the [Serenity/JS code base on GitHub](https://github.com/serenity-js/serenity-js/tree/main/packages).
|
|
206
|
-
* Also note that all the [Serenity/JS modules](/handbook/
|
|
207
|
+
* Also note that all the [Serenity/JS modules](https://serenity-js.org/handbook/getting-started/architecture)
|
|
207
208
|
* have their automated tests written in such a way to not only provide an **extremely high test coverage** for the framework itself,
|
|
208
209
|
* but to be **accessible** and act as a **reference implementation for you** to create your own integrations.
|
|
209
210
|
*
|
|
210
211
|
* If you believe that the custom integration you've developed could benefit the wider Serenity/JS community,
|
|
211
|
-
* please consider open-sourcing it yourself, or [contributing it](/contributing) to the main framework.
|
|
212
|
+
* please consider open-sourcing it yourself, or [contributing it](https://serenity-js.org/community/contributing/) to the main framework.
|
|
212
213
|
*
|
|
213
214
|
* [](https://matrix.to/#/#serenity-js:gitter.im)
|
|
214
215
|
*
|
|
@@ -266,8 +267,9 @@ exports.Ability = void 0;
|
|
|
266
267
|
* ## Using auto-initialisable and auto-discardable abilities
|
|
267
268
|
*
|
|
268
269
|
* Abilities that rely on resources that need to be initialised before they can be used,
|
|
269
|
-
* or discarded before the actor is dismissed can implement
|
|
270
|
-
*
|
|
270
|
+
* or discarded before the actor is dismissed can implement
|
|
271
|
+
* the [`Initialisable`](https://serenity-js.org/api/core/interface/Initialisable/)
|
|
272
|
+
* or [`Discardable`](https://serenity-js.org/api/core/interface/Discardable/) interfaces, respectively.
|
|
271
273
|
*
|
|
272
274
|
* ### Defining a custom ability to `QueryPostgresDB`
|
|
273
275
|
*
|
|
@@ -348,19 +350,19 @@ exports.Ability = void 0;
|
|
|
348
350
|
* ```
|
|
349
351
|
*
|
|
350
352
|
* ## Learn more
|
|
351
|
-
* -
|
|
352
|
-
* -
|
|
353
|
-
* -
|
|
354
|
-
* -
|
|
355
|
-
* -
|
|
356
|
-
* -
|
|
353
|
+
* - [`AbilityType`](https://serenity-js.org/api/core/#AbilityType)
|
|
354
|
+
* - [`Initialisable`](https://serenity-js.org/api/core/interface/Initialisable/)
|
|
355
|
+
* - [`Discardable`](https://serenity-js.org/api/core/interface/Discardable/)
|
|
356
|
+
* - [`BrowseTheWeb`](https://serenity-js.org/api/web/class/BrowseTheWeb/)
|
|
357
|
+
* - [`CallAnApi`](https://serenity-js.org/api/rest/class/CallAnApi/)
|
|
358
|
+
* - [`TakeNotes`](https://serenity-js.org/api/core/class/TakeNotes/)
|
|
357
359
|
*
|
|
358
360
|
* @group Screenplay Pattern
|
|
359
361
|
*/
|
|
360
362
|
class Ability {
|
|
361
363
|
/**
|
|
362
|
-
* Used to access an
|
|
363
|
-
* from within the
|
|
364
|
+
* Used to access an [actor's](https://serenity-js.org/api/core/class/Actor/) [ability](https://serenity-js.org/api/core/class/Ability/) of the given type
|
|
365
|
+
* from within the [`Interaction`](https://serenity-js.org/api/core/class/Interaction/) and [`Question`](https://serenity-js.org/api/core/class/Question/) classes.
|
|
364
366
|
*
|
|
365
367
|
* #### Retrieving an ability in an interaction definition
|
|
366
368
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Ability.js","sourceRoot":"","sources":["../../../src/screenplay/abilities/Ability.ts"],"names":[],"mappings":";;;AAGA
|
|
1
|
+
{"version":3,"file":"Ability.js","sourceRoot":"","sources":["../../../src/screenplay/abilities/Ability.ts"],"names":[],"mappings":";;;AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqWG;AACH,MAAsB,OAAO;IAEzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoCG;IACH,MAAM,CAAC,EAAE,CAEL,KAAoB;QAEpB,OAAO,KAAK,CAAC,SAAS,CAAC,IAAI,CAAM,CAAC;IACtC,CAAC;CACJ;AA7CD,0BA6CC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Ability } from './Ability';
|
|
2
2
|
/**
|
|
3
|
-
* An interface describing the static access method that every
|
|
4
|
-
* needs to provide in order to be accessible from within the
|
|
3
|
+
* An interface describing the static access method that every [`Ability`](https://serenity-js.org/api/core/class/Ability/) class
|
|
4
|
+
* needs to provide in order to be accessible from within the [interactions](https://serenity-js.org/api/core/class/Interaction/).
|
|
5
5
|
*
|
|
6
6
|
* #### Retrieving an ability from an interaction
|
|
7
7
|
*
|
|
@@ -35,9 +35,9 @@ import type { Ability } from './Ability';
|
|
|
35
35
|
* ```
|
|
36
36
|
*
|
|
37
37
|
* ## Learn more
|
|
38
|
-
* -
|
|
39
|
-
* -
|
|
40
|
-
* -
|
|
38
|
+
* - [`Ability`](https://serenity-js.org/api/core/class/Ability/)
|
|
39
|
+
* - [`Actor`](https://serenity-js.org/api/core/class/Actor/)
|
|
40
|
+
* - [`Interaction`](https://serenity-js.org/api/core/class/Interaction/)
|
|
41
41
|
*
|
|
42
42
|
* @group Abilities
|
|
43
43
|
*/
|
|
@@ -3,11 +3,11 @@ import type { AnswersQuestions } from '../questions';
|
|
|
3
3
|
import { Ability } from './Ability';
|
|
4
4
|
import type { UsesAbilities } from './UsesAbilities';
|
|
5
5
|
/**
|
|
6
|
-
* This
|
|
6
|
+
* This [`Ability`](https://serenity-js.org/api/core/class/Ability/) enables an [`Actor`](https://serenity-js.org/api/core/class/Actor/) to resolve the value of a given [`Answerable`](https://serenity-js.org/api/core/#Answerable).
|
|
7
7
|
*
|
|
8
|
-
*
|
|
8
|
+
* `AnswerQuestions` is used internally by [`Actor.answer`](https://serenity-js.org/api/core/class/Actor/#answer), and it is unlikely you'll ever need to use it directly in your code.
|
|
9
9
|
* That is, unless you're building a custom Serenity/JS extension and want to override the default behaviour of the framework,
|
|
10
|
-
* in which case you should check out the [Contributor's Guide](/contributing).
|
|
10
|
+
* in which case you should check out the [Contributor's Guide](https://serenity-js.org/community/contributing/).
|
|
11
11
|
*
|
|
12
12
|
* @group Abilities
|
|
13
13
|
*/
|
|
@@ -5,11 +5,11 @@ const io_1 = require("../../io");
|
|
|
5
5
|
const Question_1 = require("../Question");
|
|
6
6
|
const Ability_1 = require("./Ability");
|
|
7
7
|
/**
|
|
8
|
-
* This
|
|
8
|
+
* This [`Ability`](https://serenity-js.org/api/core/class/Ability/) enables an [`Actor`](https://serenity-js.org/api/core/class/Actor/) to resolve the value of a given [`Answerable`](https://serenity-js.org/api/core/#Answerable).
|
|
9
9
|
*
|
|
10
|
-
*
|
|
10
|
+
* `AnswerQuestions` is used internally by [`Actor.answer`](https://serenity-js.org/api/core/class/Actor/#answer), and it is unlikely you'll ever need to use it directly in your code.
|
|
11
11
|
* That is, unless you're building a custom Serenity/JS extension and want to override the default behaviour of the framework,
|
|
12
|
-
* in which case you should check out the [Contributor's Guide](/contributing).
|
|
12
|
+
* in which case you should check out the [Contributor's Guide](https://serenity-js.org/community/contributing/).
|
|
13
13
|
*
|
|
14
14
|
* @group Abilities
|
|
15
15
|
*/
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import type { Ability } from './Ability';
|
|
2
2
|
import type { UsesAbilities } from './UsesAbilities';
|
|
3
3
|
/**
|
|
4
|
-
* Describes an
|
|
4
|
+
* Describes an [`Actor`](https://serenity-js.org/api/core/class/Actor/) who can have an [`Ability`](https://serenity-js.org/api/core/class/Ability/) to perform some [`Activity`](https://serenity-js.org/api/core/class/Activity/).
|
|
5
5
|
*
|
|
6
6
|
* ## Learn more
|
|
7
7
|
*
|
|
8
|
-
* -
|
|
9
|
-
* -
|
|
8
|
+
* - [`Ability`](https://serenity-js.org/api/core/class/Ability/)
|
|
9
|
+
* - [`Actor`](https://serenity-js.org/api/core/class/Actor/)
|
|
10
10
|
*
|
|
11
11
|
* @group Actors
|
|
12
12
|
*/
|
|
13
13
|
export interface CanHaveAbilities<Returned_Type = UsesAbilities> {
|
|
14
14
|
/**
|
|
15
|
-
* Assigns an
|
|
15
|
+
* Assigns an [`Ability`](https://serenity-js.org/api/core/class/Ability/) or several abilities to the [`Actor`](https://serenity-js.org/api/core/class/Actor/)
|
|
16
16
|
*/
|
|
17
17
|
whoCan(...abilities: Ability[]): Returned_Type;
|
|
18
18
|
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* An interface to be implemented by any
|
|
2
|
+
* An interface to be implemented by any [`Ability`](https://serenity-js.org/api/core/class/Ability/) that needs to free up
|
|
3
3
|
* the resources it uses, e.g. disconnect from a database.
|
|
4
4
|
*
|
|
5
|
-
* This
|
|
6
|
-
* - when
|
|
7
|
-
* - when
|
|
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
8
|
*
|
|
9
|
-
* Note that events such as
|
|
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
10
|
* such as `@serenity-js/cucumber`, `@serenity-js/mocha`, `@serenity-js/jasmine`, and so on.
|
|
11
11
|
* Consult their respective readmes to learn how to register them with your test runner of choice.
|
|
12
12
|
*
|
|
13
13
|
* ## Learn more
|
|
14
|
-
* -
|
|
15
|
-
* -
|
|
16
|
-
* -
|
|
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
17
|
*
|
|
18
18
|
* @group Abilities
|
|
19
19
|
*/
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* An interface to be implemented by any
|
|
2
|
+
* An interface to be implemented by any [`Ability`](https://serenity-js.org/api/core/class/Ability/) that needs to initialise
|
|
3
3
|
* the resources it uses, e.g. establish a database connection.
|
|
4
4
|
*
|
|
5
|
-
* The
|
|
6
|
-
* but **only when**
|
|
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
7
|
*
|
|
8
8
|
* ## Learn more
|
|
9
|
-
* -
|
|
10
|
-
* -
|
|
11
|
-
* -
|
|
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
12
|
*
|
|
13
13
|
* @group Abilities
|
|
14
14
|
*/
|
|
15
15
|
export interface Initialisable {
|
|
16
16
|
/**
|
|
17
|
-
* Initialises the ability. Invoked whenever
|
|
18
|
-
* but **only when**
|
|
17
|
+
* Initialises the ability. Invoked whenever [`Actor.attemptsTo`](https://serenity-js.org/api/core/class/Actor/#attemptsTo) method is called,
|
|
18
|
+
* but **only when** [`Initialisable.isInitialised`](https://serenity-js.org/api/core/interface/Initialisable/#isInitialised) returns false.
|
|
19
19
|
*
|
|
20
|
-
* Make sure to implement
|
|
20
|
+
* Make sure to implement [`Initialisable.isInitialised`](https://serenity-js.org/api/core/interface/Initialisable/#isInitialised) so that it returns `true`
|
|
21
21
|
* when the ability has been successfully initialised.
|
|
22
22
|
*/
|
|
23
23
|
initialise(): Promise<void> | void;
|
|
24
24
|
/**
|
|
25
25
|
* Should return `true` when all the resources that the given ability needs
|
|
26
|
-
* have been initialised. Should return `false` if the
|
|
27
|
-
* initialise them again when
|
|
26
|
+
* have been initialised. Should return `false` if the [`Actor`](https://serenity-js.org/api/core/class/Actor/) should
|
|
27
|
+
* initialise them again when [`Actor.attemptsTo`](https://serenity-js.org/api/core/class/Actor/#attemptsTo) is called.
|
|
28
28
|
*
|
|
29
29
|
* @returns {boolean}
|
|
30
30
|
*/
|
|
@@ -6,11 +6,11 @@ import type { AnswersQuestions } from '../questions';
|
|
|
6
6
|
import { Ability } from './Ability';
|
|
7
7
|
import type { UsesAbilities } from './UsesAbilities';
|
|
8
8
|
/**
|
|
9
|
-
* An
|
|
9
|
+
* An [`Ability`](https://serenity-js.org/api/core/class/Ability/) that enables an [`Actor`](https://serenity-js.org/api/core/class/Actor/) to perform a given [`Activity`](https://serenity-js.org/api/core/class/Activity/).
|
|
10
10
|
*
|
|
11
|
-
*
|
|
11
|
+
* [`PerformActivities`](https://serenity-js.org/api/core/class/PerformActivities/) is used internally by [`Actor.attemptsTo`](https://serenity-js.org/api/core/class/Actor/#attemptsTo), and it is unlikely you'll ever need to use it directly in your code.
|
|
12
12
|
* That is, unless you're building a custom Serenity/JS extension and want to override the default behaviour of the framework,
|
|
13
|
-
* in which case you should check out the [Contributor's Guide](/contributing).
|
|
13
|
+
* in which case you should check out the [Contributor's Guide](https://serenity-js.org/community/contributing).
|
|
14
14
|
*
|
|
15
15
|
* @group Abilities
|
|
16
16
|
*/
|
|
@@ -9,11 +9,11 @@ const model_1 = require("../../model");
|
|
|
9
9
|
const Interaction_1 = require("../Interaction");
|
|
10
10
|
const Ability_1 = require("./Ability");
|
|
11
11
|
/**
|
|
12
|
-
* An
|
|
12
|
+
* An [`Ability`](https://serenity-js.org/api/core/class/Ability/) that enables an [`Actor`](https://serenity-js.org/api/core/class/Actor/) to perform a given [`Activity`](https://serenity-js.org/api/core/class/Activity/).
|
|
13
13
|
*
|
|
14
|
-
*
|
|
14
|
+
* [`PerformActivities`](https://serenity-js.org/api/core/class/PerformActivities/) is used internally by [`Actor.attemptsTo`](https://serenity-js.org/api/core/class/Actor/#attemptsTo), and it is unlikely you'll ever need to use it directly in your code.
|
|
15
15
|
* That is, unless you're building a custom Serenity/JS extension and want to override the default behaviour of the framework,
|
|
16
|
-
* in which case you should check out the [Contributor's Guide](/contributing).
|
|
16
|
+
* in which case you should check out the [Contributor's Guide](https://serenity-js.org/community/contributing).
|
|
17
17
|
*
|
|
18
18
|
* @group Abilities
|
|
19
19
|
*/
|