@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
package/src/screenplay/Task.ts
CHANGED
|
@@ -4,8 +4,8 @@ import { Activity } from './Activity';
|
|
|
4
4
|
import type { Answerable } from './Answerable';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* **Tasks** model **
|
|
8
|
-
* and help you capture meaningful steps of an
|
|
7
|
+
* **Tasks** model **[sequences of activities](https://serenity-js.org/api/core/class/Activity/)**
|
|
8
|
+
* and help you capture meaningful steps of an [actor](https://serenity-js.org/api/core/class/Actor/) workflow
|
|
9
9
|
* in your domain.
|
|
10
10
|
*
|
|
11
11
|
* Typically, tasks correspond to higher-level, business domain-specific activities
|
|
@@ -13,20 +13,20 @@ import type { Answerable } from './Answerable';
|
|
|
13
13
|
* However, higher-level tasks can and should be composed of lower-level tasks.
|
|
14
14
|
* For example, a task to `SignUp` could be composed of tasks to `ProvideUsername` and `ProvidePassword`.
|
|
15
15
|
*
|
|
16
|
-
* The lowest-level tasks in your abstraction hierarchy should be composed of
|
|
17
|
-
* For example, a low-level task to `ProvideUsername` could be composed of an interaction to
|
|
18
|
-
* into a form field and
|
|
16
|
+
* The lowest-level tasks in your abstraction hierarchy should be composed of [interactions](https://serenity-js.org/api/core/class/Interaction/).
|
|
17
|
+
* For example, a low-level task to `ProvideUsername` could be composed of an interaction to [enter](https://serenity-js.org/api/web/class/Enter/) the value
|
|
18
|
+
* into a form field and [press](https://serenity-js.org/api/web/class/Press/) the [`Key.Enter`](https://serenity-js.org/api/web/class/Key/#Enter).
|
|
19
19
|
*
|
|
20
|
-
* Tasks are the core building block of the [Screenplay Pattern](/handbook/design/screenplay-pattern),
|
|
21
|
-
* along with
|
|
20
|
+
* Tasks are the core building block of the [Screenplay Pattern](https://serenity-js.org/handbook/design/screenplay-pattern),
|
|
21
|
+
* along with [actors](https://serenity-js.org/api/core/class/Actor/), [abilities](https://serenity-js.org/api/core/class/Ability/), [interactions](https://serenity-js.org/api/core/class/Interaction/), and [questions](https://serenity-js.org/api/core/class/Question/).
|
|
22
22
|
*
|
|
23
|
-
* 
|
|
23
|
+
* 
|
|
24
24
|
*
|
|
25
25
|
* Learn more about:
|
|
26
26
|
* - [User-Centred Design: How a 50 year old technique became the key to scalable test automation](https://janmolak.com/user-centred-design-how-a-50-year-old-technique-became-the-key-to-scalable-test-automation-66a658a36555)
|
|
27
|
-
* -
|
|
28
|
-
* -
|
|
29
|
-
* -
|
|
27
|
+
* - [Actors](https://serenity-js.org/api/core/class/Actor/)
|
|
28
|
+
* - [Activities](https://serenity-js.org/api/core/class/Activity/)
|
|
29
|
+
* - [Interactions](https://serenity-js.org/api/core/class/Interaction/)
|
|
30
30
|
*
|
|
31
31
|
* ## Defining a task
|
|
32
32
|
*
|
|
@@ -44,7 +44,7 @@ import type { Answerable } from './Answerable';
|
|
|
44
44
|
*
|
|
45
45
|
* ## Defining a not implemented task
|
|
46
46
|
*
|
|
47
|
-
* Note that calling
|
|
47
|
+
* Note that calling [`Task.where`](https://serenity-js.org/api/core/class/Task/#where) method without providing the sequence of [activities](https://serenity-js.org/api/core/class/Activity/)
|
|
48
48
|
* produces a Task that's marked as "pending" in the test report.
|
|
49
49
|
*
|
|
50
50
|
* This feature is useful when you want to quickly write down a task that will be needed in the scenario,
|
|
@@ -72,7 +72,7 @@ import type { Answerable } from './Answerable';
|
|
|
72
72
|
* - specify origin city of "London"
|
|
73
73
|
* - specify destination city of "New York"
|
|
74
74
|
*
|
|
75
|
-
* The easiest way to implement such task, and any custom Serenity/JS task for this matter, is to use the
|
|
75
|
+
* The easiest way to implement such task, and any custom Serenity/JS task for this matter, is to use the [`Task.where`](https://serenity-js.org/api/core/class/Task/#where) method to compose the lower-level activities:
|
|
76
76
|
*
|
|
77
77
|
* ```typescript
|
|
78
78
|
* import { Task, the } from '@serenity-js/core'
|
|
@@ -94,9 +94,9 @@ import type { Answerable } from './Answerable';
|
|
|
94
94
|
* - enter city name of `New York`
|
|
95
95
|
* - pick the first suggested airport from the list
|
|
96
96
|
*
|
|
97
|
-
* Conveniently, [Serenity/JS modules](/handbook/
|
|
97
|
+
* Conveniently, [Serenity/JS modules](https://serenity-js.org/handbook/getting-started/architecture) provide low-level activities that
|
|
98
98
|
* allow actors to interact with the various interfaces of the system under test.
|
|
99
|
-
* For example, [Serenity/JS Web module](/api/web) ships with activities such as
|
|
99
|
+
* For example, [Serenity/JS Web module](https://serenity-js.org/api/web) ships with activities such as [`Click`](https://serenity-js.org/api/web/class/Click/) or [`Enter`](https://serenity-js.org/api/web/class/Enter/),
|
|
100
100
|
* which we can incorporate into our task definitions just like any other activities:
|
|
101
101
|
*
|
|
102
102
|
* ```typescript
|
|
@@ -190,14 +190,14 @@ export abstract class Task extends Activity {
|
|
|
190
190
|
}
|
|
191
191
|
|
|
192
192
|
/**
|
|
193
|
-
* Instructs the provided
|
|
193
|
+
* Instructs the provided [`Actor`](https://serenity-js.org/api/core/class/Actor/) to perform this [`Task`](https://serenity-js.org/api/core/class/Task/).
|
|
194
194
|
*
|
|
195
195
|
* @param {PerformsActivities} actor
|
|
196
196
|
*
|
|
197
197
|
* #### Learn more
|
|
198
|
-
* -
|
|
199
|
-
* -
|
|
200
|
-
* -
|
|
198
|
+
* - [`Actor`](https://serenity-js.org/api/core/class/Actor/)
|
|
199
|
+
* - [`PerformsActivities`](https://serenity-js.org/api/core/interface/PerformsActivities/)
|
|
200
|
+
* - [`Activity`](https://serenity-js.org/api/core/class/Activity/)
|
|
201
201
|
*/
|
|
202
202
|
abstract performAs(actor: PerformsActivities): Promise<void>;
|
|
203
203
|
}
|
|
@@ -2,8 +2,8 @@ import type { Answerable } from './Answerable';
|
|
|
2
2
|
import type { Question } from './Question';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Describes a plain JavaScript object with
|
|
6
|
-
* Typically, used in conjunction with
|
|
5
|
+
* Describes a plain JavaScript object with [`Answerable`](https://serenity-js.org/api/core/#Answerable) properties.
|
|
6
|
+
* Typically, used in conjunction with [`RecursivelyAnswered`](https://serenity-js.org/api/core/#RecursivelyAnswered) and [`Question.fromObject`](https://serenity-js.org/api/core/class/Question/#fromObject).
|
|
7
7
|
*
|
|
8
8
|
* ```ts
|
|
9
9
|
* import {
|
|
@@ -2,37 +2,38 @@ import type { AbilityType } from './AbilityType';
|
|
|
2
2
|
import type { UsesAbilities } from './UsesAbilities';
|
|
3
3
|
|
|
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 @@ import type { UsesAbilities } from './UsesAbilities';
|
|
|
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 @@ import type { UsesAbilities } from './UsesAbilities';
|
|
|
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 @@ import type { UsesAbilities } from './UsesAbilities';
|
|
|
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 @@ import type { UsesAbilities } from './UsesAbilities';
|
|
|
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 @@ import type { UsesAbilities } from './UsesAbilities';
|
|
|
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 @@ import type { UsesAbilities } from './UsesAbilities';
|
|
|
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 @@ import type { UsesAbilities } from './UsesAbilities';
|
|
|
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,20 +350,20 @@ import type { UsesAbilities } from './UsesAbilities';
|
|
|
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
|
export abstract class Ability {
|
|
361
363
|
|
|
362
364
|
/**
|
|
363
|
-
* Used to access an
|
|
364
|
-
* from within the
|
|
365
|
+
* 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
|
|
366
|
+
* from within the [`Interaction`](https://serenity-js.org/api/core/class/Interaction/) and [`Question`](https://serenity-js.org/api/core/class/Question/) classes.
|
|
365
367
|
*
|
|
366
368
|
* #### Retrieving an ability in an interaction definition
|
|
367
369
|
*
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Ability } from './Ability';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* An interface describing the static access method that every
|
|
5
|
-
* needs to provide in order to be accessible from within the
|
|
4
|
+
* An interface describing the static access method that every [`Ability`](https://serenity-js.org/api/core/class/Ability/) class
|
|
5
|
+
* needs to provide in order to be accessible from within the [interactions](https://serenity-js.org/api/core/class/Interaction/).
|
|
6
6
|
*
|
|
7
7
|
* #### Retrieving an ability from an interaction
|
|
8
8
|
*
|
|
@@ -36,9 +36,9 @@ import type { Ability } from './Ability';
|
|
|
36
36
|
* ```
|
|
37
37
|
*
|
|
38
38
|
* ## Learn more
|
|
39
|
-
* -
|
|
40
|
-
* -
|
|
41
|
-
* -
|
|
39
|
+
* - [`Ability`](https://serenity-js.org/api/core/class/Ability/)
|
|
40
|
+
* - [`Actor`](https://serenity-js.org/api/core/class/Actor/)
|
|
41
|
+
* - [`Interaction`](https://serenity-js.org/api/core/class/Interaction/)
|
|
42
42
|
*
|
|
43
43
|
* @group Abilities
|
|
44
44
|
*/
|
|
@@ -6,11 +6,11 @@ import { Ability } from './Ability';
|
|
|
6
6
|
import type { UsesAbilities } from './UsesAbilities';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* This
|
|
9
|
+
* 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).
|
|
10
10
|
*
|
|
11
|
-
*
|
|
11
|
+
* `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.
|
|
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
|
*/
|
|
@@ -2,19 +2,19 @@ import type { Ability } from './Ability';
|
|
|
2
2
|
import type { UsesAbilities } from './UsesAbilities';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Describes an
|
|
5
|
+
* 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/).
|
|
6
6
|
*
|
|
7
7
|
* ## Learn more
|
|
8
8
|
*
|
|
9
|
-
* -
|
|
10
|
-
* -
|
|
9
|
+
* - [`Ability`](https://serenity-js.org/api/core/class/Ability/)
|
|
10
|
+
* - [`Actor`](https://serenity-js.org/api/core/class/Actor/)
|
|
11
11
|
*
|
|
12
12
|
* @group Actors
|
|
13
13
|
*/
|
|
14
14
|
export interface CanHaveAbilities<Returned_Type = UsesAbilities> {
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
* Assigns an
|
|
17
|
+
* 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/)
|
|
18
18
|
*/
|
|
19
19
|
whoCan(...abilities: Ability[]): Returned_Type;
|
|
20
20
|
}
|
|
@@ -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,32 +1,32 @@
|
|
|
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
17
|
/**
|
|
18
|
-
* Initialises the ability. Invoked whenever
|
|
19
|
-
* but **only when**
|
|
18
|
+
* Initialises the ability. Invoked whenever [`Actor.attemptsTo`](https://serenity-js.org/api/core/class/Actor/#attemptsTo) method is called,
|
|
19
|
+
* but **only when** [`Initialisable.isInitialised`](https://serenity-js.org/api/core/interface/Initialisable/#isInitialised) returns false.
|
|
20
20
|
*
|
|
21
|
-
* Make sure to implement
|
|
21
|
+
* Make sure to implement [`Initialisable.isInitialised`](https://serenity-js.org/api/core/interface/Initialisable/#isInitialised) so that it returns `true`
|
|
22
22
|
* when the ability has been successfully initialised.
|
|
23
23
|
*/
|
|
24
24
|
initialise(): Promise<void> | void;
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* Should return `true` when all the resources that the given ability needs
|
|
28
|
-
* have been initialised. Should return `false` if the
|
|
29
|
-
* initialise them again when
|
|
28
|
+
* have been initialised. Should return `false` if the [`Actor`](https://serenity-js.org/api/core/class/Actor/) should
|
|
29
|
+
* initialise them again when [`Actor.attemptsTo`](https://serenity-js.org/api/core/class/Actor/#attemptsTo) is called.
|
|
30
30
|
*
|
|
31
31
|
* @returns {boolean}
|
|
32
32
|
*/
|
|
@@ -22,11 +22,11 @@ import { Ability } from './Ability';
|
|
|
22
22
|
import type { UsesAbilities } from './UsesAbilities';
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
|
-
* An
|
|
25
|
+
* 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/).
|
|
26
26
|
*
|
|
27
|
-
*
|
|
27
|
+
* [`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.
|
|
28
28
|
* That is, unless you're building a custom Serenity/JS extension and want to override the default behaviour of the framework,
|
|
29
|
-
* in which case you should check out the [Contributor's Guide](/contributing).
|
|
29
|
+
* in which case you should check out the [Contributor's Guide](https://serenity-js.org/community/contributing).
|
|
30
30
|
*
|
|
31
31
|
* @group Abilities
|
|
32
32
|
*/
|
|
@@ -2,23 +2,23 @@ import type { Ability } from './Ability';
|
|
|
2
2
|
import type { AbilityType } from './AbilityType';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Describes an
|
|
6
|
-
* or answer a
|
|
5
|
+
* Describes an [`Actor`](https://serenity-js.org/api/core/class/Actor/) who can use their [abilities](https://serenity-js.org/api/core/class/Ability/) to perform an [`Activity`](https://serenity-js.org/api/core/class/Activity/)
|
|
6
|
+
* or answer a [`Question`](https://serenity-js.org/api/core/class/Question/).
|
|
7
7
|
*
|
|
8
8
|
* ## Learn more
|
|
9
9
|
*
|
|
10
|
-
* -
|
|
11
|
-
* -
|
|
10
|
+
* - [`Ability`](https://serenity-js.org/api/core/class/Ability/)
|
|
11
|
+
* - [`Actor`](https://serenity-js.org/api/core/class/Actor/)
|
|
12
12
|
*
|
|
13
13
|
* @group Actors
|
|
14
14
|
*/
|
|
15
15
|
export interface UsesAbilities {
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
* Provides access to the
|
|
18
|
+
* Provides access to the [actor's](https://serenity-js.org/api/core/class/Actor/) [`Ability`](https://serenity-js.org/api/core/class/Ability/) to do something
|
|
19
19
|
*
|
|
20
20
|
* @param doSomething
|
|
21
|
-
* The type of ability to look up, e.g.
|
|
21
|
+
* The type of ability to look up, e.g. [`BrowseTheWeb`](https://serenity-js.org/api/web/class/BrowseTheWeb/) or [`CallAnApi`](https://serenity-js.org/api/rest/class/CallAnApi/)
|
|
22
22
|
*/
|
|
23
23
|
abilityTo<T extends Ability>(doSomething: AbilityType<T>): T;
|
|
24
24
|
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import type { Activity } from '../Activity';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Describes an
|
|
5
|
-
* such as
|
|
4
|
+
* Describes an [`Actor`](https://serenity-js.org/api/core/class/Actor/) who can perform a sequence of [activities](https://serenity-js.org/api/core/class/Activity/),
|
|
5
|
+
* such as [tasks](https://serenity-js.org/api/core/class/Task/) or [interactions](https://serenity-js.org/api/core/class/Interaction/).
|
|
6
6
|
*
|
|
7
7
|
* ## Learn more
|
|
8
|
-
* -
|
|
9
|
-
* -
|
|
10
|
-
* -
|
|
11
|
-
* -
|
|
8
|
+
* - [`Activity`](https://serenity-js.org/api/core/class/Activity/)
|
|
9
|
+
* - [`Interaction`](https://serenity-js.org/api/core/class/Interaction/)
|
|
10
|
+
* - [`Task`](https://serenity-js.org/api/core/class/Task/)
|
|
11
|
+
* - [`Actor`](https://serenity-js.org/api/core/class/Actor/)
|
|
12
12
|
*
|
|
13
13
|
* @group Actors
|
|
14
14
|
*/
|
|
15
15
|
export interface PerformsActivities {
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
* Makes the
|
|
18
|
+
* Makes the [`Actor`](https://serenity-js.org/api/core/class/Actor/) attempt to perform a sequence of [activities](https://serenity-js.org/api/core/class/Activity/).
|
|
19
19
|
*/
|
|
20
20
|
attemptsTo: (...activities: Activity[]) => Promise<void>;
|
|
21
21
|
}
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import type { Artifact, Name } from '../../model';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Describes an
|
|
4
|
+
* Describes an [`Actor`](https://serenity-js.org/api/core/class/Actor/) who can collect artifacts, such as photos or `JSON` data.,
|
|
5
5
|
* while the scenario is being executed
|
|
6
6
|
*
|
|
7
7
|
* ## Learn more
|
|
8
|
-
* -
|
|
9
|
-
* - {@apilink Actor}
|
|
8
|
+
* - [`Actor`](https://serenity-js.org/api/core/class/Actor/)
|
|
10
9
|
*
|
|
11
10
|
* @group Actors
|
|
12
11
|
*/
|
|
13
12
|
export interface CollectsArtifacts {
|
|
14
13
|
|
|
15
14
|
/**
|
|
16
|
-
* Makes the
|
|
15
|
+
* Makes the [`Actor`](https://serenity-js.org/api/core/class/Actor/) collect an artifact so that it can be included in the test report.
|
|
17
16
|
*
|
|
18
17
|
* #### Implementing a custom interaction to attach artifacts
|
|
19
18
|
*
|
|
@@ -70,7 +69,7 @@ export interface CollectsArtifacts {
|
|
|
70
69
|
* ```
|
|
71
70
|
*
|
|
72
71
|
* @param artifact
|
|
73
|
-
* The artifact to be collected, such as
|
|
72
|
+
* The artifact to be collected, such as `JSON` data.
|
|
74
73
|
*
|
|
75
74
|
* @param name
|
|
76
75
|
* The name of the artifact to make it easy to recognise in the test report
|
|
@@ -11,7 +11,7 @@ import type { AnswersQuestions } from '../questions';
|
|
|
11
11
|
import type { DebuggingResult } from './DebuggingResult';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
* Instructs the
|
|
14
|
+
* Instructs the [actor](https://serenity-js.org/api/core/class/Actor/) to evaluate and [log](https://serenity-js.org/api/core/class/Log/) the provided [answerable](https://serenity-js.org/api/core/#Answerable) values.
|
|
15
15
|
*
|
|
16
16
|
* Since this interaction **accepts a callback function** that receives the evaluated results,
|
|
17
17
|
* the best way to use it is while **running the test scenario via a Node.js debugger**.
|
|
@@ -19,8 +19,8 @@ import type { DebuggingResult } from './DebuggingResult';
|
|
|
19
19
|
*
|
|
20
20
|
* ## Debugging Answerable values
|
|
21
21
|
*
|
|
22
|
-
*
|
|
23
|
-
* as well as the result of evaluating each provided
|
|
22
|
+
* [`Debug.values`](https://serenity-js.org/api/core/class/Debug/#values) accepts a callback function that receives an array of [`DebuggingResult`](https://serenity-js.org/api/core/interface/DebuggingResult/) objects,
|
|
23
|
+
* as well as the result of evaluating each provided [answerable](https://serenity-js.org/api/core/#Answerable) with [`Actor.answer`](https://serenity-js.org/api/core/class/Actor/#answer).
|
|
24
24
|
*
|
|
25
25
|
* ```typescript
|
|
26
26
|
* import { actorCalled, Debug } from '@serenity-js/core'
|
|
@@ -43,8 +43,9 @@ import type { DebuggingResult } from './DebuggingResult';
|
|
|
43
43
|
* provides features that allow for [experimenting with web UI locators](https://marketplace.visualstudio.com/items?itemName=ms-playwright.playwright#tune-locators)
|
|
44
44
|
* while the test is paused at breakpoint.
|
|
45
45
|
*
|
|
46
|
-
* Since this functionality is specific to [Playwright](/api/playwright),
|
|
47
|
-
*
|
|
46
|
+
* Since this functionality is specific to [Playwright](https://serenity-js.org/api/playwright),
|
|
47
|
+
* you can use it by passing [`PlaywrightPage.current().nativePage()`](https://serenity-js.org/api/playwright/class/PlaywrightPage/#current)
|
|
48
|
+
* to Serenity/JS [`Debug.values`](https://serenity-js.org/api/core/class/Debug/#values). Also make sure to name the evaluated value `page`, as this is the variable name that the Playwright VSCode extension expects.
|
|
48
49
|
*
|
|
49
50
|
* ```typescript
|
|
50
51
|
* import { actorCalled, Debug } from '@serenity-js/core'
|
|
@@ -74,7 +75,7 @@ import type { DebuggingResult } from './DebuggingResult';
|
|
|
74
75
|
export class Debug<Values extends Array<Answerable<unknown>>> extends Interaction {
|
|
75
76
|
|
|
76
77
|
/**
|
|
77
|
-
* Instructs the
|
|
78
|
+
* Instructs the [actor](https://serenity-js.org/api/core/class/Actor/) to evaluate the provided `values`,
|
|
78
79
|
* log the results, and then pass them to your `debuggerFunction`.
|
|
79
80
|
*
|
|
80
81
|
* To use this interaction, run your test scenario in the Node.js debugger
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* An interface describing debugging data received by the callback function passed to
|
|
2
|
+
* An interface describing debugging data received by the callback function passed to [`Debug.values`](https://serenity-js.org/api/core/class/Debug/#values).
|
|
3
3
|
*
|
|
4
4
|
* @group Activities
|
|
5
5
|
*/
|