@serenity-js/playwright-test 3.31.17 → 3.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/README.md +6 -5
- package/lib/api/PlaywrightTestConfig.d.ts +2 -2
- package/lib/api/PlaywrightTestConfig.d.ts.map +1 -1
- package/lib/api/WorkerEventStreamReader.d.ts +13 -0
- package/lib/api/WorkerEventStreamReader.d.ts.map +1 -0
- package/lib/api/WorkerEventStreamReader.js +58 -0
- package/lib/api/WorkerEventStreamReader.js.map +1 -0
- package/lib/api/WorkerEventStreamWriter.d.ts +24 -0
- package/lib/api/WorkerEventStreamWriter.d.ts.map +1 -0
- package/lib/api/WorkerEventStreamWriter.js +86 -0
- package/lib/api/WorkerEventStreamWriter.js.map +1 -0
- package/lib/api/index.d.ts +1 -2
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.js +1 -2
- package/lib/api/index.js.map +1 -1
- package/lib/api/serenity-fixtures.d.ts +377 -0
- package/lib/api/serenity-fixtures.d.ts.map +1 -0
- package/lib/api/{SerenityOptions.js → serenity-fixtures.js} +1 -1
- package/lib/api/serenity-fixtures.js.map +1 -0
- package/lib/api/test-api.d.ts +27 -15
- package/lib/api/test-api.d.ts.map +1 -1
- package/lib/api/test-api.js +126 -104
- package/lib/api/test-api.js.map +1 -1
- package/lib/events/EventFactory.d.ts +16 -0
- package/lib/events/EventFactory.d.ts.map +1 -0
- package/lib/events/EventFactory.js +94 -0
- package/lib/events/EventFactory.js.map +1 -0
- package/lib/events/PlaywrightSceneId.d.ts +7 -0
- package/lib/events/PlaywrightSceneId.d.ts.map +1 -0
- package/lib/events/PlaywrightSceneId.js +19 -0
- package/lib/events/PlaywrightSceneId.js.map +1 -0
- package/lib/events/index.d.ts +3 -0
- package/lib/events/index.d.ts.map +1 -0
- package/lib/events/index.js +19 -0
- package/lib/events/index.js.map +1 -0
- package/lib/reporter/PlaywrightErrorParser.d.ts +7 -0
- package/lib/reporter/PlaywrightErrorParser.d.ts.map +1 -0
- package/lib/reporter/PlaywrightErrorParser.js +28 -0
- package/lib/reporter/PlaywrightErrorParser.js.map +1 -0
- package/lib/reporter/PlaywrightEventBuffer.d.ts +25 -0
- package/lib/reporter/PlaywrightEventBuffer.d.ts.map +1 -0
- package/lib/reporter/PlaywrightEventBuffer.js +147 -0
- package/lib/reporter/PlaywrightEventBuffer.js.map +1 -0
- package/lib/reporter/PlaywrightTestSceneIdFactory.d.ts +8 -0
- package/lib/reporter/PlaywrightTestSceneIdFactory.d.ts.map +1 -0
- package/lib/reporter/PlaywrightTestSceneIdFactory.js +15 -0
- package/lib/reporter/PlaywrightTestSceneIdFactory.js.map +1 -0
- package/lib/reporter/SerenityReporterForPlaywrightTest.d.ts +11 -20
- package/lib/reporter/SerenityReporterForPlaywrightTest.d.ts.map +1 -1
- package/lib/reporter/SerenityReporterForPlaywrightTest.js +62 -163
- package/lib/reporter/SerenityReporterForPlaywrightTest.js.map +1 -1
- package/lib/reporter/index.d.ts +0 -2
- package/lib/reporter/index.d.ts.map +1 -1
- package/lib/reporter/index.js +0 -2
- package/lib/reporter/index.js.map +1 -1
- package/package.json +9 -9
- package/src/api/PlaywrightTestConfig.ts +2 -2
- package/src/api/WorkerEventStreamReader.ts +27 -0
- package/src/api/WorkerEventStreamWriter.ts +117 -0
- package/src/api/index.ts +1 -2
- package/src/api/serenity-fixtures.ts +392 -0
- package/src/api/test-api.ts +187 -99
- package/src/events/EventFactory.ts +204 -0
- package/src/events/PlaywrightSceneId.ts +20 -0
- package/src/events/index.ts +2 -0
- package/src/reporter/PlaywrightErrorParser.ts +35 -0
- package/src/reporter/PlaywrightEventBuffer.ts +251 -0
- package/src/reporter/PlaywrightTestSceneIdFactory.ts +14 -0
- package/src/reporter/SerenityReporterForPlaywrightTest.ts +85 -248
- package/src/reporter/index.ts +0 -2
- package/lib/api/SerenityFixtures.d.ts +0 -130
- package/lib/api/SerenityFixtures.d.ts.map +0 -1
- package/lib/api/SerenityFixtures.js +0 -3
- package/lib/api/SerenityFixtures.js.map +0 -1
- package/lib/api/SerenityOptions.d.ts +0 -271
- package/lib/api/SerenityOptions.d.ts.map +0 -1
- package/lib/api/SerenityOptions.js.map +0 -1
- package/lib/reporter/DomainEventBuffer.d.ts +0 -11
- package/lib/reporter/DomainEventBuffer.d.ts.map +0 -1
- package/lib/reporter/DomainEventBuffer.js +0 -24
- package/lib/reporter/DomainEventBuffer.js.map +0 -1
- package/lib/reporter/PlaywrightAttachments.d.ts +0 -2
- package/lib/reporter/PlaywrightAttachments.d.ts.map +0 -1
- package/lib/reporter/PlaywrightAttachments.js +0 -5
- package/lib/reporter/PlaywrightAttachments.js.map +0 -1
- package/src/api/SerenityFixtures.ts +0 -132
- package/src/api/SerenityOptions.ts +0 -277
- package/src/reporter/DomainEventBuffer.ts +0 -28
- package/src/reporter/PlaywrightAttachments.ts +0 -1
|
@@ -1,277 +0,0 @@
|
|
|
1
|
-
import type { PlaywrightTestOptions, PlaywrightWorkerArgs, TestFixture } from '@playwright/test';
|
|
2
|
-
import type { Cast, ClassDescription, Duration, StageCrewMember, StageCrewMemberBuilder } from '@serenity-js/core';
|
|
3
|
-
import type { PlaywrightOptions } from '@serenity-js/playwright';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Configuration object accepted by `@serenity-js/playwright-test`.
|
|
7
|
-
*
|
|
8
|
-
* ## Example
|
|
9
|
-
*
|
|
10
|
-
* ```typescript
|
|
11
|
-
* // playwright.config.ts
|
|
12
|
-
* import type { Cast, TakeNotes } from '@serenity-js/core'
|
|
13
|
-
* import type { BrowseTheWebWithPlaywright } from '@serenity-js/playwright'
|
|
14
|
-
* import type { PlaywrightTestConfig } from '@serenity-js/playwright-test'
|
|
15
|
-
* import type { CallAnApi } from '@serenity-js/rest'
|
|
16
|
-
*
|
|
17
|
-
* // Define any custom configuration options, if needed
|
|
18
|
-
* interface MyCustomOptions {
|
|
19
|
-
* apiUrl: string;
|
|
20
|
-
* }
|
|
21
|
-
*
|
|
22
|
-
* const config: PlaywrightTestConfig<MyCustomOptions> = {
|
|
23
|
-
*
|
|
24
|
-
* // Register Serenity/JS reporter for Playwright Test
|
|
25
|
-
* // to enable integration with Serenity/JS stage crew members
|
|
26
|
-
* // and have them instantiated in the Playwright reporter process
|
|
27
|
-
* reporter: [
|
|
28
|
-
* [ '@serenity-js/playwright-test', {
|
|
29
|
-
* // Stage crew members instantiated in the test reporter process
|
|
30
|
-
* crew: [
|
|
31
|
-
* '@serenity-js/serenity-bdd',
|
|
32
|
-
* '@serenity-js/console-reporter',
|
|
33
|
-
* [ '@serenity-js/core:ArtifactArchiver', { outputDirectory: 'target/site/serenity' } ],
|
|
34
|
-
* ]
|
|
35
|
-
* }]
|
|
36
|
-
* ],
|
|
37
|
-
*
|
|
38
|
-
* use: {
|
|
39
|
-
*
|
|
40
|
-
* // Register Serenity/JS stage crew members
|
|
41
|
-
* // and have them instantiated in Playwright Test worker processes
|
|
42
|
-
* crew: [
|
|
43
|
-
* [ '@serenity-js/web:Photographer', { strategy: 'TakePhotosOfFailures' } ]
|
|
44
|
-
* ],
|
|
45
|
-
*
|
|
46
|
-
* // Register a custom cast of Serenity/JS actors
|
|
47
|
-
* // if you don't want to use the default ones
|
|
48
|
-
* actors: ({ browser, contextOptions, apiUrl }, use) => {
|
|
49
|
-
* const cast = Cast.where(actor =>
|
|
50
|
-
* actor.whoCan(
|
|
51
|
-
* BrowseTheWebWithPlaywright.using(browser, contextOptions),
|
|
52
|
-
* TakeNotes.usingAnEmptyNotepad(),
|
|
53
|
-
* CallAnApi.at(apiUrl),
|
|
54
|
-
* )
|
|
55
|
-
* )
|
|
56
|
-
*
|
|
57
|
-
* use(cast)
|
|
58
|
-
* },
|
|
59
|
-
*
|
|
60
|
-
* // Name to be given to an actor injected via `actor` fixture
|
|
61
|
-
* defaultActorName: 'Alice',
|
|
62
|
-
*
|
|
63
|
-
* // Any custom options, as per the MyCustomOptions interface
|
|
64
|
-
* apiUrl: 'https://api.serenity-js.org/v1'
|
|
65
|
-
*
|
|
66
|
-
* // Any other Playwright options
|
|
67
|
-
* baseURL: 'https://todo-app.serenity-js.org/',
|
|
68
|
-
* video: 'on-first-retry',
|
|
69
|
-
* trace: 'on-first-retry',
|
|
70
|
-
* },
|
|
71
|
-
* }
|
|
72
|
-
*
|
|
73
|
-
* export default config
|
|
74
|
-
* ```
|
|
75
|
-
*
|
|
76
|
-
* ## Learn more
|
|
77
|
-
* - [`PlaywrightTestConfig`](https://serenity-js.org/api/playwright-test/#PlaywrightTestConfig)
|
|
78
|
-
* - [`Cast`](https://serenity-js.org/api/core/class/Cast/)
|
|
79
|
-
* - [`SerenityFixtures`](https://serenity-js.org/api/playwright-test/interface/SerenityFixtures/)
|
|
80
|
-
*/
|
|
81
|
-
export interface SerenityOptions {
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Configures the [`Cast`](https://serenity-js.org/api/core/class/Cast/) of [`actors`](https://serenity-js.org/api/core/class/SerenityConfig/#actors) to be used when injecting an [`actor`](https://serenity-js.org/api/playwright-test/interface/SerenityFixtures/#actor)
|
|
85
|
-
* or invoking [`actorCalled`](https://serenity-js.org/api/playwright-test/interface/SerenityFixtures/#actorCalled) in a [test scenario](https://serenity-js.org/api/playwright-test/function/it/).
|
|
86
|
-
*
|
|
87
|
-
* :::info Did you know?
|
|
88
|
-
* When you use `@serenity-js/playwright-test` [test APIs](https://serenity-js.org/api/playwright-test/function/it/), Serenity/JS already provides a default cast of actors for you.
|
|
89
|
-
* Each one of the default actors receives [abilities](https://serenity-js.org/api/core/class/Ability/) to [`BrowseTheWebWithPlaywright`](https://serenity-js.org/api/playwright/class/BrowseTheWebWithPlaywright/) and [`TakeNotes.usingAnEmptyNotepad`](https://serenity-js.org/api/core/class/TakeNotes/#usingAnEmptyNotepad).
|
|
90
|
-
*
|
|
91
|
-
* The default abilities should be sufficient in most web testing scenarios. However, you might want to override this default configuration
|
|
92
|
-
* when you need your actors to [interact with REST APIs](https://serenity-js.org/api/rest/class/CallAnApi/),
|
|
93
|
-
* [manage local servers](https://serenity-js.org/api/local-server/class/ManageALocalServer/),
|
|
94
|
-
* start with a notepad that has some [initial state](https://serenity-js.org/api/core/class/TakeNotes/#using),
|
|
95
|
-
* or receive [custom abilities](https://serenity-js.org/api/core/class/Ability/).
|
|
96
|
-
* :::
|
|
97
|
-
*
|
|
98
|
-
* #### Using a custom crew of Serenity/JS actors
|
|
99
|
-
*
|
|
100
|
-
* ```typescript
|
|
101
|
-
* // playwright.config.ts
|
|
102
|
-
* import type { PlaywrightTestConfig } from '@serenity-js/playwright-test'
|
|
103
|
-
* import { Cast, TakeNotes } from '@serenity-js/core'
|
|
104
|
-
* import { BrowseTheWebWithPlaywright } from '@serenity-js/playwright'
|
|
105
|
-
* import { CallAnApi } from '@serenity-js/rest'
|
|
106
|
-
*
|
|
107
|
-
* // Define any custom configuration options, if needed
|
|
108
|
-
* interface MyCustomOptions {
|
|
109
|
-
* apiUrl: string;
|
|
110
|
-
* }
|
|
111
|
-
*
|
|
112
|
-
* // Parameterise PlaywrightTestConfig with MyCustomOptions
|
|
113
|
-
* // to enable type checking of any custom properties
|
|
114
|
-
* const config: PlaywrightTestConfig<MyCustomOptions> = {
|
|
115
|
-
* use: {
|
|
116
|
-
* contextOptions: {
|
|
117
|
-
* defaultNavigationTimeout: 30_000,
|
|
118
|
-
* },
|
|
119
|
-
*
|
|
120
|
-
* // custom properties
|
|
121
|
-
* apiUrl: 'https://api.serenity-js.org/v1',
|
|
122
|
-
*
|
|
123
|
-
* // Custom cast of actors receives `contextOptions`
|
|
124
|
-
* // with the additional Serenity/JS properties (see `PlaywrightOptions`),
|
|
125
|
-
* // as well as any other custom properties you define in the destructuring expression,
|
|
126
|
-
* // such as `apiUrl`.
|
|
127
|
-
* actors: ({ browser, contextOptions, apiUrl }, use) => {
|
|
128
|
-
* const cast = Cast.where(actor => actor.whoCan(
|
|
129
|
-
* BrowseTheWebWithPlaywright.using(browser, contextOptions),
|
|
130
|
-
* TakeNotes.usingAnEmptyNotepad(),
|
|
131
|
-
* CallAnApi.at(apiUrl),
|
|
132
|
-
* ))
|
|
133
|
-
*
|
|
134
|
-
* // Make sure to pass your custom cast to Playwright `use` callback
|
|
135
|
-
* use(cast)
|
|
136
|
-
* },
|
|
137
|
-
* },
|
|
138
|
-
* };
|
|
139
|
-
* export default config
|
|
140
|
-
* ```
|
|
141
|
-
*
|
|
142
|
-
* #### Learn more
|
|
143
|
-
* - Declaring a Serenity/JS [test scenario](https://serenity-js.org/api/playwright-test/function/it/)
|
|
144
|
-
* - [`SerenityFixtures`](https://serenity-js.org/api/playwright-test/interface/SerenityFixtures/)
|
|
145
|
-
*/
|
|
146
|
-
actors: TestFixture<Cast, PlaywrightTestOptions & PlaywrightWorkerArgs>
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Configures the name given to the default Serenity/JS [`actor`](https://serenity-js.org/api/playwright-test/interface/SerenityFixtures/#actor)
|
|
150
|
-
* injected into a [test scenario](https://serenity-js.org/api/playwright-test/function/it/).
|
|
151
|
-
*
|
|
152
|
-
* #### Learn more
|
|
153
|
-
* - Declaring a Serenity/JS [test scenario](https://serenity-js.org/api/playwright-test/function/it/)
|
|
154
|
-
* - [`SerenityFixtures`](https://serenity-js.org/api/playwright-test/interface/SerenityFixtures/)
|
|
155
|
-
*/
|
|
156
|
-
defaultActorName: string;
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Configures the [stage crew members](https://serenity-js.org/api/core/class/SerenityConfig/#crew)
|
|
160
|
-
* to be instantiated in Playwright Test worker processes.
|
|
161
|
-
*
|
|
162
|
-
* :::info Did you know?
|
|
163
|
-
* By default, Serenity/JS registers a [`Photographer`](https://serenity-js.org/api/web/class/Photographer/).whoWill([`TakePhotosOfFailures`](https://serenity-js.org/api/web/class/TakePhotosOfFailures/)),
|
|
164
|
-
* so that any test failures are automatically accompanied by a screenshot.
|
|
165
|
-
*
|
|
166
|
-
* If you prefer a different behaviour, you can configure the `crew` with an empty array to disable taking screenshots altogether (`crew: []`),
|
|
167
|
-
* or with a [`Photographer`](https://serenity-js.org/api/web/class/Photographer/) who uses a different [`PhotoTakingStrategy`](https://serenity-js.org/api/web/class/PhotoTakingStrategy/), like to [`TakePhotosOfInteractions`](https://serenity-js.org/api/web/class/TakePhotosOfInteractions/).
|
|
168
|
-
* :::
|
|
169
|
-
*
|
|
170
|
-
* #### Example
|
|
171
|
-
*
|
|
172
|
-
* ```typescript
|
|
173
|
-
* // playwright.config.ts
|
|
174
|
-
* import type { PlaywrightTestConfig } from '@serenity-js/playwright-test'
|
|
175
|
-
*
|
|
176
|
-
* const config: PlaywrightTestConfig = {
|
|
177
|
-
* use: {
|
|
178
|
-
* crew: [
|
|
179
|
-
* [ '@serenity-js/web:Photographer', { strategy: 'TakePhotosOfFailures' } ]
|
|
180
|
-
* ],
|
|
181
|
-
* },
|
|
182
|
-
* };
|
|
183
|
-
* export default config
|
|
184
|
-
* ```
|
|
185
|
-
*
|
|
186
|
-
* #### Learn more
|
|
187
|
-
* - [`SerenityConfig.crew`](https://serenity-js.org/api/core/class/SerenityConfig/#crew)
|
|
188
|
-
*/
|
|
189
|
-
crew: Array<ClassDescription | StageCrewMember | StageCrewMemberBuilder>;
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Sets the [`cueTimeout`](https://serenity-js.org/api/core/class/SerenityConfig/#cueTimeout) to a given [duration](https://serenity-js.org/api/core/class/Duration/) or a numeric value in milliseconds.
|
|
193
|
-
* Defaults to **5 seconds**.
|
|
194
|
-
*
|
|
195
|
-
* #### Learn more
|
|
196
|
-
* - [`SerenityConfig.cueTimeout`](https://serenity-js.org/api/core/class/SerenityConfig/#cueTimeout)
|
|
197
|
-
* - [`Discardable`](https://serenity-js.org/api/core/interface/Discardable/)
|
|
198
|
-
* - [`Ability`](https://serenity-js.org/api/core/class/Ability/)
|
|
199
|
-
*/
|
|
200
|
-
cueTimeout: number | Duration;
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* The maximum default amount of time allowed for interactions such as [`Wait.until`](https://serenity-js.org/api/core/class/Wait/#until)
|
|
204
|
-
* to complete.
|
|
205
|
-
*
|
|
206
|
-
* Defaults to **5 seconds**, can be overridden per interaction.
|
|
207
|
-
*
|
|
208
|
-
* #### Learn more
|
|
209
|
-
* - [`Wait.until`](https://serenity-js.org/api/core/class/Wait/#until)
|
|
210
|
-
*/
|
|
211
|
-
interactionTimeout?: Duration;
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* Playwright [BrowserContextOptions](https://playwright.dev/docs/api/class-testoptions#test-options-context-options),
|
|
215
|
-
* augmented with several convenience properties to be used with the [ability](https://serenity-js.org/api/core/class/Ability/)
|
|
216
|
-
* to [`BrowseTheWebWithPlaywright`](https://serenity-js.org/api/playwright/class/BrowseTheWebWithPlaywright/).
|
|
217
|
-
*
|
|
218
|
-
* Additional convenience properties include:
|
|
219
|
-
* - [`PlaywrightOptions.defaultNavigationTimeout`](https://serenity-js.org/api/playwright/interface/PlaywrightOptions/#defaultNavigationTimeout)
|
|
220
|
-
* - [`PlaywrightOptions.defaultNavigationWaitUntil`](https://serenity-js.org/api/playwright/interface/PlaywrightOptions/#defaultNavigationWaitUntil)
|
|
221
|
-
* - [`PlaywrightOptions.defaultTimeout`](https://serenity-js.org/api/playwright/interface/PlaywrightOptions/#defaultTimeout)
|
|
222
|
-
*
|
|
223
|
-
* #### Using `contextOptions` with the default cast of Serenity/JS actors
|
|
224
|
-
*
|
|
225
|
-
* ```typescript
|
|
226
|
-
* // playwright.config.ts
|
|
227
|
-
* import type { PlaywrightTestConfig } from '@serenity-js/playwright-test'
|
|
228
|
-
*
|
|
229
|
-
* const config: PlaywrightTestConfig = {
|
|
230
|
-
* use: {
|
|
231
|
-
* contextOptions: {
|
|
232
|
-
* defaultNavigationTimeout: 30_000,
|
|
233
|
-
* }
|
|
234
|
-
*
|
|
235
|
-
* // Since `actors` property is not defined,
|
|
236
|
-
* // `contextOptions` will be passed to the default cast of Serenity/JS actors
|
|
237
|
-
* // and injected into the ability to `BrowseTheWebWithPlaywright`
|
|
238
|
-
* // that each actor receives.
|
|
239
|
-
* },
|
|
240
|
-
* };
|
|
241
|
-
* export default config;
|
|
242
|
-
* ```
|
|
243
|
-
*
|
|
244
|
-
* #### Using `contextOptions` with a custom cast of Serenity/JS actors
|
|
245
|
-
*
|
|
246
|
-
* ```typescript
|
|
247
|
-
* // playwright.config.ts
|
|
248
|
-
* import type { PlaywrightTestConfig } from '@serenity-js/playwright-test'
|
|
249
|
-
*
|
|
250
|
-
* const config: PlaywrightTestConfig = {
|
|
251
|
-
* use: {
|
|
252
|
-
* contextOptions: {
|
|
253
|
-
* defaultNavigationTimeout: 30_000,
|
|
254
|
-
* }
|
|
255
|
-
*
|
|
256
|
-
* // Custom cast of actors receives `contextOptions` with the
|
|
257
|
-
* // additional Serenity/JS properties.
|
|
258
|
-
* actors: ({ browser, contextOptions }, use) => {
|
|
259
|
-
* const cast = Cast.where(actor => actor.whoCan(
|
|
260
|
-
* BrowseTheWebWithPlaywright.using(browser, contextOptions),
|
|
261
|
-
* TakeNotes.usingAnEmptyNotepad(),
|
|
262
|
-
* ))
|
|
263
|
-
*
|
|
264
|
-
* use(cast)
|
|
265
|
-
* },
|
|
266
|
-
* },
|
|
267
|
-
* };
|
|
268
|
-
* export default config;
|
|
269
|
-
* ```
|
|
270
|
-
*
|
|
271
|
-
* #### Learn more
|
|
272
|
-
* - [`SerenityFixtures`](https://serenity-js.org/api/playwright-test/interface/SerenityFixtures/)
|
|
273
|
-
* - [Playwright Browser Context options](https://playwright.dev/docs/api/class-testoptions#test-options-context-options)
|
|
274
|
-
* - [Playwright Test fixtures](https://playwright.dev/docs/test-fixtures)
|
|
275
|
-
*/
|
|
276
|
-
contextOptions: PlaywrightOptions;
|
|
277
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { Stage, StageCrewMember } from '@serenity-js/core';
|
|
2
|
-
import type { DomainEvent } from '@serenity-js/core/lib/events';
|
|
3
|
-
|
|
4
|
-
export class DomainEventBuffer implements StageCrewMember {
|
|
5
|
-
|
|
6
|
-
private events: DomainEvent[] = [];
|
|
7
|
-
|
|
8
|
-
constructor(private stage?: Stage) {
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
assignedTo(stage: Stage): StageCrewMember {
|
|
12
|
-
this.stage = stage;
|
|
13
|
-
|
|
14
|
-
return this;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
notifyOf(event: DomainEvent): void {
|
|
18
|
-
this.events.push(event);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
flush(): DomainEvent[] {
|
|
22
|
-
const events = [...this.events];
|
|
23
|
-
|
|
24
|
-
this.events = [];
|
|
25
|
-
|
|
26
|
-
return events;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const SERENITY_JS_DOMAIN_EVENTS_ATTACHMENT_CONTENT_TYPE = 'application/vnd.serenity-js.domain-events+json';
|