@serenity-js/playwright-test 3.31.17 → 3.32.1
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 +37 -0
- package/README.md +6 -5
- package/lib/api/PlaywrightTestConfig.d.ts +7 -6
- 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 +15 -22
- 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 +7 -6
- 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 +89 -250
- 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
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
import type { Cast, ClassDescription, Duration, Serenity, StageCrewMember, StageCrewMemberBuilder } from '@serenity-js/core';
|
|
2
|
+
import type { Actor } from '@serenity-js/core';
|
|
3
|
+
import type { ExtraBrowserContextOptions } from '@serenity-js/playwright';
|
|
4
|
+
/**
|
|
5
|
+
* Serenity/JS-specific [Playwright Test fixtures](https://playwright.dev/docs/test-fixtures)
|
|
6
|
+
* injected into your [test scenarios](https://serenity-js.org/api/playwright-test/function/it/).
|
|
7
|
+
*
|
|
8
|
+
* ### Configuring Serenity/JS using a test file
|
|
9
|
+
*
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { Ensure, equals } from '@serenity-js/assertions'
|
|
12
|
+
* import { describe, it, test } from '@serenity-js/playwright-test'
|
|
13
|
+
* import { Photographer, TakePhotosOfFailures } from '@serenity-js/web'
|
|
14
|
+
*
|
|
15
|
+
* describe(`Recording items`, () => {
|
|
16
|
+
*
|
|
17
|
+
* test.use({
|
|
18
|
+
* defaultActorName: 'Serena',
|
|
19
|
+
* crew: [
|
|
20
|
+
* Photographer.whoWill(TakePhotosOfFailures),
|
|
21
|
+
* ],
|
|
22
|
+
*
|
|
23
|
+
* // Register a custom cast of Serenity/JS actors to replace the default one
|
|
24
|
+
* actors: async ({ browser, contextOptions, extraContextOptions, baseURL }, use) => {
|
|
25
|
+
* const cast = Cast.where(actor =>
|
|
26
|
+
* actor.whoCan(
|
|
27
|
+
* BrowseTheWebWithPlaywright.using(browser, contextOptions, extraContextOptions),
|
|
28
|
+
* TakeNotes.usingAnEmptyNotepad(),
|
|
29
|
+
* CallAnApi.at(baseURL),
|
|
30
|
+
* )
|
|
31
|
+
* )
|
|
32
|
+
*
|
|
33
|
+
* await use(cast)
|
|
34
|
+
* },
|
|
35
|
+
* })
|
|
36
|
+
*
|
|
37
|
+
* describe(`Todo List App`, () => {
|
|
38
|
+
*
|
|
39
|
+
* it(`should allow me to add a todo item`, async ({ actor }) => {
|
|
40
|
+
* await actor.attemptsTo(
|
|
41
|
+
* startWithAnEmptyList(),
|
|
42
|
+
*
|
|
43
|
+
* recordItem('Buy some milk'),
|
|
44
|
+
*
|
|
45
|
+
* Ensure.that(itemNames(), equals([
|
|
46
|
+
* 'Buy some milk',
|
|
47
|
+
* ])),
|
|
48
|
+
* )
|
|
49
|
+
* })
|
|
50
|
+
* })
|
|
51
|
+
* })
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* ### Configuring Serenity/JS using Playwright configuration file
|
|
55
|
+
*
|
|
56
|
+
* ```typescript
|
|
57
|
+
* // playwright.config.ts
|
|
58
|
+
* import { defineConfig } from '@playwright/test'
|
|
59
|
+
* import type { Cast, TakeNotes } from '@serenity-js/core'
|
|
60
|
+
* import type { BrowseTheWebWithPlaywright } from '@serenity-js/playwright'
|
|
61
|
+
* import type { SerenityFixtures, SerenityWorkerFixtures } from '@serenity-js/playwright-test'
|
|
62
|
+
* import type { CallAnApi } from '@serenity-js/rest'
|
|
63
|
+
*
|
|
64
|
+
* export default defineConfig<SerenityFixtures & MyCustomOptions, SerenityWorkerFixtures> = {
|
|
65
|
+
*
|
|
66
|
+
* // Register Serenity/JS reporter for Playwright Test
|
|
67
|
+
* // to enable integration with Serenity/JS stage crew members
|
|
68
|
+
* // and have them instantiated in the Playwright reporter process
|
|
69
|
+
* reporter: [
|
|
70
|
+
* [ '@serenity-js/playwright-test', {
|
|
71
|
+
* // Stage crew members instantiated in the test reporter process
|
|
72
|
+
* crew: [
|
|
73
|
+
* '@serenity-js/serenity-bdd',
|
|
74
|
+
* '@serenity-js/console-reporter',
|
|
75
|
+
* [ '@serenity-js/core:ArtifactArchiver', { outputDirectory: 'target/site/serenity' } ],
|
|
76
|
+
* ]
|
|
77
|
+
* }]
|
|
78
|
+
* ],
|
|
79
|
+
*
|
|
80
|
+
* use: {
|
|
81
|
+
*
|
|
82
|
+
* // Register Serenity/JS stage crew members
|
|
83
|
+
* // and have them instantiated in Playwright Test worker processes
|
|
84
|
+
* crew: [
|
|
85
|
+
* [ '@serenity-js/web:Photographer', { strategy: 'TakePhotosOfFailures' } ]
|
|
86
|
+
* ],
|
|
87
|
+
*
|
|
88
|
+
* // Name to be given to an actor injected via `actor` fixture
|
|
89
|
+
* defaultActorName: 'Alice',
|
|
90
|
+
*
|
|
91
|
+
* // Any other Playwright options
|
|
92
|
+
* baseURL: 'https://todo-app.serenity-js.org/',
|
|
93
|
+
* video: 'on-first-retry',
|
|
94
|
+
* trace: 'on-first-retry',
|
|
95
|
+
* },
|
|
96
|
+
* })
|
|
97
|
+
* ```
|
|
98
|
+
*
|
|
99
|
+
* ## Learn more
|
|
100
|
+
* - [Using Serenity/JS with Playwright Test](https://serenity-js.org/handbook/test-runners/playwright-test/)
|
|
101
|
+
* - [`PlaywrightTestConfig`](https://serenity-js.org/api/playwright-test/#PlaywrightTestConfig)
|
|
102
|
+
* - [`Cast`](https://serenity-js.org/api/core/class/Cast/)
|
|
103
|
+
* - [`SerenityFixtures`](https://serenity-js.org/api/playwright-test/interface/SerenityFixtures/)
|
|
104
|
+
*/
|
|
105
|
+
export interface SerenityFixtures {
|
|
106
|
+
/**
|
|
107
|
+
* Configures the name given to the default Serenity/JS [`actor`](https://serenity-js.org/api/playwright-test/interface/SerenityFixtures/#actor)
|
|
108
|
+
* injected into a [test scenario](https://serenity-js.org/api/playwright-test/function/it/).
|
|
109
|
+
*
|
|
110
|
+
* #### Learn more
|
|
111
|
+
* - Declaring a Serenity/JS [test scenario](https://serenity-js.org/api/playwright-test/function/it/)
|
|
112
|
+
* - [`SerenityFixtures`](https://serenity-js.org/api/playwright-test/interface/SerenityFixtures/)
|
|
113
|
+
*/
|
|
114
|
+
defaultActorName: string;
|
|
115
|
+
/**
|
|
116
|
+
* Configures the [stage crew members](https://serenity-js.org/api/core/class/SerenityConfig/#crew)
|
|
117
|
+
* to be instantiated in Playwright Test worker processes.
|
|
118
|
+
*
|
|
119
|
+
* :::info Did you know?
|
|
120
|
+
* 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/)),
|
|
121
|
+
* so that any test failures are automatically accompanied by a screenshot.
|
|
122
|
+
*
|
|
123
|
+
* If you prefer a different behaviour, you can configure the `crew` with an empty array to disable taking screenshots altogether (`crew: []`),
|
|
124
|
+
* 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/).
|
|
125
|
+
* :::
|
|
126
|
+
*
|
|
127
|
+
* #### Example
|
|
128
|
+
*
|
|
129
|
+
* ```typescript
|
|
130
|
+
* // playwright.config.ts
|
|
131
|
+
* import type { SerenityFixtures, SerenityWorkerFixtures } from '@serenity-js/playwright-test'
|
|
132
|
+
* import { defineConfig } from '@playwright/test'
|
|
133
|
+
*
|
|
134
|
+
* export default defineConfig<SerenityFixtures, SerenityWorkerFixtures>({
|
|
135
|
+
* use: {
|
|
136
|
+
* crew: [
|
|
137
|
+
* [ '@serenity-js/web:Photographer', { strategy: 'TakePhotosOfFailures' } ]
|
|
138
|
+
* ],
|
|
139
|
+
* },
|
|
140
|
+
* });
|
|
141
|
+
* ```
|
|
142
|
+
*
|
|
143
|
+
* #### Learn more
|
|
144
|
+
* - [`SerenityConfig.crew`](https://serenity-js.org/api/core/class/SerenityConfig/#crew)
|
|
145
|
+
*/
|
|
146
|
+
crew: Array<ClassDescription | StageCrewMember | StageCrewMemberBuilder>;
|
|
147
|
+
/**
|
|
148
|
+
* 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.
|
|
149
|
+
* Defaults to **5 seconds**.
|
|
150
|
+
*
|
|
151
|
+
* #### Learn more
|
|
152
|
+
* - [`SerenityConfig.cueTimeout`](https://serenity-js.org/api/core/class/SerenityConfig/#cueTimeout)
|
|
153
|
+
* - [`Discardable`](https://serenity-js.org/api/core/interface/Discardable/)
|
|
154
|
+
* - [`Ability`](https://serenity-js.org/api/core/class/Ability/)
|
|
155
|
+
*/
|
|
156
|
+
cueTimeout: number | Duration;
|
|
157
|
+
/**
|
|
158
|
+
* The maximum default amount of time allowed for interactions such as [`Wait.until`](https://serenity-js.org/api/core/class/Wait/#until)
|
|
159
|
+
* to complete.
|
|
160
|
+
*
|
|
161
|
+
* Defaults to **5 seconds**, can be overridden per interaction.
|
|
162
|
+
*
|
|
163
|
+
* #### Learn more
|
|
164
|
+
* - [`Wait.until`](https://serenity-js.org/api/core/class/Wait/#until)
|
|
165
|
+
*/
|
|
166
|
+
interactionTimeout: number | Duration;
|
|
167
|
+
/**
|
|
168
|
+
* Convenience properties to be used with the [ability](https://serenity-js.org/api/core/class/Ability/)
|
|
169
|
+
* to [`BrowseTheWebWithPlaywright`](https://serenity-js.org/api/playwright/class/BrowseTheWebWithPlaywright/),
|
|
170
|
+
* in addition to Playwright [BrowserContextOptions](https://playwright.dev/docs/api/class-testoptions#test-options-context-options):
|
|
171
|
+
*
|
|
172
|
+
* - [`defaultNavigationTimeout`](https://serenity-js.org/api/playwright/interface/ExtraBrowserContextOptions/#defaultNavigationTimeout)
|
|
173
|
+
* - [`defaultNavigationWaitUntil`](https://serenity-js.org/api/playwright/interface/ExtraBrowserContextOptions/#defaultNavigationWaitUntil)
|
|
174
|
+
* - [`defaultTimeout`](https://serenity-js.org/api/playwright/interface/ExtraBrowserContextOptions/#defaultTimeout)
|
|
175
|
+
*
|
|
176
|
+
* #### Using `extraContextOptions` with the default cast of Serenity/JS actors
|
|
177
|
+
*
|
|
178
|
+
* ```typescript
|
|
179
|
+
* // playwright.config.ts
|
|
180
|
+
* import type { SerenityFixtures, SerenityWorkerFixtures } from '@serenity-js/playwright-test'
|
|
181
|
+
* import { defineConfig } from '@playwright/test'
|
|
182
|
+
*
|
|
183
|
+
* export default defineConfig<SerenityFixtures, SerenityWorkerFixtures>({
|
|
184
|
+
* use: {
|
|
185
|
+
* extraContextOptions: {
|
|
186
|
+
* defaultNavigationTimeout: 30_000,
|
|
187
|
+
* }
|
|
188
|
+
*
|
|
189
|
+
* // Since `actors` property is not defined,
|
|
190
|
+
* // `extraContextOptions` will be passed to the default cast of Serenity/JS actors
|
|
191
|
+
* // and injected into the ability to `BrowseTheWebWithPlaywright`
|
|
192
|
+
* // that each actor receives.
|
|
193
|
+
* },
|
|
194
|
+
* })
|
|
195
|
+
* ```
|
|
196
|
+
*
|
|
197
|
+
* #### Using `extraContextOptions` with a custom cast of Serenity/JS actors
|
|
198
|
+
*
|
|
199
|
+
* ```typescript
|
|
200
|
+
* // playwright.config.ts
|
|
201
|
+
* import type { SerenityFixtures, SerenityWorkerFixtures } from '@serenity-js/playwright-test'
|
|
202
|
+
* import { defineConfig } from '@playwright/test'
|
|
203
|
+
*
|
|
204
|
+
* export default defineConfig<SerenityFixtures, SerenityWorkerFixtures>({
|
|
205
|
+
* use: {
|
|
206
|
+
* extraContextOptions: {
|
|
207
|
+
* defaultNavigationTimeout: 30_000,
|
|
208
|
+
* }
|
|
209
|
+
*
|
|
210
|
+
* // Custom cast of actors receives the default `contextOptions` and
|
|
211
|
+
* // the `extraContextOptions` with the additional Serenity/JS properties.
|
|
212
|
+
* actors: async ({ browser, contextOptions, extraContextOptions }, use) => {
|
|
213
|
+
* const cast = Cast.where(actor => actor.whoCan(
|
|
214
|
+
* BrowseTheWebWithPlaywright.using(browser, contextOptions, extraContextOptions),
|
|
215
|
+
* TakeNotes.usingAnEmptyNotepad(),
|
|
216
|
+
* ))
|
|
217
|
+
*
|
|
218
|
+
* await use(cast)
|
|
219
|
+
* },
|
|
220
|
+
* },
|
|
221
|
+
* })
|
|
222
|
+
* ```
|
|
223
|
+
*
|
|
224
|
+
* #### Learn more
|
|
225
|
+
* - [`SerenityFixtures`](https://serenity-js.org/api/playwright-test/interface/SerenityFixtures/)
|
|
226
|
+
* - [Playwright Browser Context options](https://playwright.dev/docs/api/class-testoptions#test-options-context-options)
|
|
227
|
+
* - [Playwright Test fixtures](https://playwright.dev/docs/test-fixtures)
|
|
228
|
+
*/
|
|
229
|
+
extraContextOptions: Partial<ExtraBrowserContextOptions>;
|
|
230
|
+
/**
|
|
231
|
+
* A cast of Serenity/JS actors to be used instead of the default cast
|
|
232
|
+
* when instantiating [`actor`](https://serenity-js.org/api/playwright-test/interface/SerenityFixtures/#actor)
|
|
233
|
+
* and invoking [`actorCalled`](https://serenity-js.org/api/playwright-test/interface/SerenityFixtures/#actorCalled).
|
|
234
|
+
*
|
|
235
|
+
* :::info Did you know?
|
|
236
|
+
* 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.
|
|
237
|
+
* 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).
|
|
238
|
+
*
|
|
239
|
+
* The default abilities should be sufficient in most web testing scenarios. However, you might want to override this default configuration
|
|
240
|
+
* when you need your actors to [interact with REST APIs](https://serenity-js.org/api/rest/class/CallAnApi/),
|
|
241
|
+
* [manage local servers](https://serenity-js.org/api/local-server/class/ManageALocalServer/),
|
|
242
|
+
* start with a notepad that has some [initial state](https://serenity-js.org/api/core/class/TakeNotes/#using),
|
|
243
|
+
* or receive [custom abilities](https://serenity-js.org/api/core/class/Ability/).
|
|
244
|
+
* :::
|
|
245
|
+
*
|
|
246
|
+
*
|
|
247
|
+
* #### Overriding the default cast of Serenity/JS actors
|
|
248
|
+
*
|
|
249
|
+
* ```typescript
|
|
250
|
+
* import { Cast, TakeNotes } from '@serenity-js/core'
|
|
251
|
+
* import { Ensure, equals } from '@serenity-js/assertions'
|
|
252
|
+
* import { BrowseTheWebWithPlaywright } from '@serenity-js/playwright'
|
|
253
|
+
* import { describe, it, test } from '@serenity-js/playwright-test'
|
|
254
|
+
*
|
|
255
|
+
* describe(`Recording items`, () => {
|
|
256
|
+
*
|
|
257
|
+
* test.use({
|
|
258
|
+
* extraContextOptions: {
|
|
259
|
+
* defaultNavigationTimeout: 30_000,
|
|
260
|
+
* },
|
|
261
|
+
*
|
|
262
|
+
* defaultActorName: 'Serena',
|
|
263
|
+
* actors: async ({ browser, contextOptions, extraContextOptions }, use) => {
|
|
264
|
+
* const cast = Cast.where(actor =>
|
|
265
|
+
* actor.whoCan(
|
|
266
|
+
* BrowseTheWebWithPlaywright.using(browser, contextOptions, extraContextOptions),
|
|
267
|
+
* TakeNotes.usingAnEmptyNotepad(),
|
|
268
|
+
* )
|
|
269
|
+
* )
|
|
270
|
+
*
|
|
271
|
+
* // Make sure to pass your custom cast to Playwright `use` callback
|
|
272
|
+
* await use(cast)
|
|
273
|
+
* },
|
|
274
|
+
* })
|
|
275
|
+
*
|
|
276
|
+
* describe(`Todo List App`, () => {
|
|
277
|
+
*
|
|
278
|
+
* it(`should allow me to add a todo item`, async ({ actor }) => {
|
|
279
|
+
* await actor.attemptsTo(
|
|
280
|
+
* startWithAnEmptyList(),
|
|
281
|
+
*
|
|
282
|
+
* recordItem('Buy some milk'),
|
|
283
|
+
*
|
|
284
|
+
* Ensure.that(itemNames(), equals([
|
|
285
|
+
* 'Buy some milk',
|
|
286
|
+
* ])),
|
|
287
|
+
* )
|
|
288
|
+
* })
|
|
289
|
+
* })
|
|
290
|
+
* })
|
|
291
|
+
*
|
|
292
|
+
*
|
|
293
|
+
* #### Learn more
|
|
294
|
+
* - Declaring a Serenity/JS [test scenario](https://serenity-js.org/api/playwright-test/function/it/)
|
|
295
|
+
* - [`SerenityFixtures`](https://serenity-js.org/api/playwright-test/interface/SerenityFixtures/)
|
|
296
|
+
*/
|
|
297
|
+
actors: Cast;
|
|
298
|
+
/**
|
|
299
|
+
* Default [`actor`](https://serenity-js.org/api/playwright-test/interface/SerenityFixtures/#actor) injected into a [test scenario](https://serenity-js.org/api/playwright-test/function/it/).
|
|
300
|
+
*
|
|
301
|
+
* Using `actor` fixture is equivalent to invoking [`actorCalled`](https://serenity-js.org/api/playwright-test/interface/SerenityFixtures/#actorCalled)
|
|
302
|
+
* with [`defaultActorName`](https://serenity-js.org/api/playwright-test/interface/SerenityFixtures/#defaultActorName).
|
|
303
|
+
*
|
|
304
|
+
* #### Learn more
|
|
305
|
+
* - [`actorCalled`](https://serenity-js.org/api/playwright-test/interface/SerenityWorkerFixtures/#actorCalled)
|
|
306
|
+
* - [`defaultActorName`](https://serenity-js.org/api/playwright-test/interface/SerenityFixtures/#defaultActorName)
|
|
307
|
+
* - Declaring a Serenity/JS [test scenario](https://serenity-js.org/api/playwright-test/function/it/)
|
|
308
|
+
*/
|
|
309
|
+
actor: Actor;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Serenity/JS-specific [Playwright Test fixtures](https://playwright.dev/docs/test-fixtures)
|
|
313
|
+
* injected into your [test scenarios](https://serenity-js.org/api/playwright-test/function/it/).
|
|
314
|
+
*
|
|
315
|
+
* ## Example test scenario
|
|
316
|
+
*
|
|
317
|
+
* ```typescript
|
|
318
|
+
* import { Ensure, equals } from '@serenity-js/assertions'
|
|
319
|
+
* import { describe, it, test } from '@serenity-js/playwright-test'
|
|
320
|
+
* import { Photographer, TakePhotosOfFailures } from '@serenity-js/web'
|
|
321
|
+
*
|
|
322
|
+
* describe(`Recording items`, () => {
|
|
323
|
+
*
|
|
324
|
+
* test.use({
|
|
325
|
+
* defaultActorName: 'Serena',
|
|
326
|
+
* crew: [
|
|
327
|
+
* Photographer.whoWill(TakePhotosOfFailures),
|
|
328
|
+
* ],
|
|
329
|
+
* })
|
|
330
|
+
*
|
|
331
|
+
* describe(`Todo List App`, () => {
|
|
332
|
+
*
|
|
333
|
+
* it(`should allow me to add a todo item`, async ({ actor }) => {
|
|
334
|
+
* await actor.attemptsTo(
|
|
335
|
+
* startWithAnEmptyList(),
|
|
336
|
+
*
|
|
337
|
+
* recordItem('Buy some milk'),
|
|
338
|
+
*
|
|
339
|
+
* Ensure.that(itemNames(), equals([
|
|
340
|
+
* 'Buy some milk',
|
|
341
|
+
* ])),
|
|
342
|
+
* )
|
|
343
|
+
* })
|
|
344
|
+
* })
|
|
345
|
+
* })
|
|
346
|
+
* ```
|
|
347
|
+
*
|
|
348
|
+
* ## Learn more
|
|
349
|
+
* - [Using Serenity/JS with Playwright Test](https://serenity-js.org/handbook/test-runners/playwright-test/)
|
|
350
|
+
*/
|
|
351
|
+
export interface SerenityWorkerFixtures {
|
|
352
|
+
/**
|
|
353
|
+
* Name and version of the operating system that Playwright Test worker process runs on.
|
|
354
|
+
*/
|
|
355
|
+
platform: {
|
|
356
|
+
name: string;
|
|
357
|
+
version: string;
|
|
358
|
+
};
|
|
359
|
+
/**
|
|
360
|
+
* Retrieves the root object of the Serenity/JS framework.
|
|
361
|
+
*/
|
|
362
|
+
serenity: Serenity;
|
|
363
|
+
/**
|
|
364
|
+
* Uses the provided [cast](https://serenity-js.org/api/core/class/Cast/) of [`actors`](https://serenity-js.org/api/playwright-test/interface/SerenityFixtures/#actors) to instantiate an [`Actor`](https://serenity-js.org/api/core/class/Actor/) called `name`
|
|
365
|
+
* and inject it into a [test scenario](https://serenity-js.org/api/playwright-test/function/it/).
|
|
366
|
+
*
|
|
367
|
+
* Retrieves an existing actor if one has already been instantiated.
|
|
368
|
+
*
|
|
369
|
+
* #### Learn more
|
|
370
|
+
* - Declaring a Serenity/JS [test scenario](https://serenity-js.org/api/playwright-test/function/it/)
|
|
371
|
+
* - [`SerenityFixtures.actors`](https://serenity-js.org/api/playwright-test/interface/SerenityFixtures/#actors)
|
|
372
|
+
*
|
|
373
|
+
* @param name
|
|
374
|
+
*/
|
|
375
|
+
actorCalled: (name: string) => Actor;
|
|
376
|
+
}
|
|
377
|
+
//# sourceMappingURL=serenity-fixtures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serenity-fixtures.d.ts","sourceRoot":"","sources":["../../src/api/serenity-fixtures.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,IAAI,EACJ,gBAAgB,EAChB,QAAQ,EACR,QAAQ,EACR,eAAe,EACf,sBAAsB,EACzB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAE1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoGG;AACH,MAAM,WAAW,gBAAgB;IAE7B;;;;;;;OAOG;IACH,gBAAgB,EAAE,MAAM,CAAC;IAEzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,IAAI,EAAE,KAAK,CAAC,gBAAgB,GAAG,eAAe,GAAG,sBAAsB,CAAC,CAAC;IAEzE;;;;;;;;OAQG;IACH,UAAU,EAAE,MAAM,GAAG,QAAQ,CAAC;IAE9B;;;;;;;;OAQG;IACH,kBAAkB,EAAE,MAAM,GAAG,QAAQ,CAAC;IAEtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6DG;IACH,mBAAmB,EAAE,OAAO,CAAC,0BAA0B,CAAC,CAAC;IAEzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkEG;IACH,MAAM,EAAE,IAAI,CAAC;IAEb;;;;;;;;;;OAUG;IACH,KAAK,EAAE,KAAK,CAAC;CAChB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,WAAW,sBAAsB;IACnC;;OAEG;IACH,QAAQ,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAE5C;;OAEG;IACH,QAAQ,EAAE,QAAQ,CAAC;IAEnB;;;;;;;;;;;OAWG;IACH,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,KAAK,CAAC;CACxC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serenity-fixtures.js","sourceRoot":"","sources":["../../src/api/serenity-fixtures.ts"],"names":[],"mappings":""}
|
package/lib/api/test-api.d.ts
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import type { Expect, Fixtures, PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions, TestInfo, TestType } from '@playwright/test';
|
|
2
|
-
import type {
|
|
3
|
-
import
|
|
4
|
-
|
|
2
|
+
import type { DiffFormatter } from '@serenity-js/core';
|
|
3
|
+
import { PlaywrightTestSceneIdFactory } from '../reporter/PlaywrightTestSceneIdFactory';
|
|
4
|
+
import type { SerenityFixtures, SerenityWorkerFixtures } from './serenity-fixtures';
|
|
5
|
+
import { WorkerEventStreamWriter } from './WorkerEventStreamWriter';
|
|
6
|
+
interface SerenityInternalFixtures {
|
|
7
|
+
configureScenarioInternal: void;
|
|
8
|
+
}
|
|
9
|
+
interface SerenityInternalWorkerFixtures {
|
|
10
|
+
configureWorkerInternal: void;
|
|
11
|
+
sceneIdFactoryInternal: PlaywrightTestSceneIdFactory;
|
|
12
|
+
diffFormatterInternal: DiffFormatter;
|
|
13
|
+
eventStreamWriterInternal: WorkerEventStreamWriter;
|
|
14
|
+
}
|
|
15
|
+
export declare const fixtures: Fixtures<SerenityFixtures & SerenityInternalFixtures, SerenityWorkerFixtures & SerenityInternalWorkerFixtures, PlaywrightTestArgs & PlaywrightTestOptions, PlaywrightWorkerArgs & PlaywrightWorkerOptions>;
|
|
5
16
|
/**
|
|
6
17
|
* Serenity/JS BDD-style test API created by [`useBase`](https://serenity-js.org/api/playwright-test/function/useBase/).
|
|
7
18
|
*/
|
|
@@ -91,11 +102,11 @@ export type TestApi<TestArgs extends Record<string, any>, WorkerArgs extends Rec
|
|
|
91
102
|
* - [Playwright Test `test` function](https://playwright.dev/docs/api/class-test#test-call)
|
|
92
103
|
* - [Serenity/JS + Playwright Test project template](https://github.com/serenity-js/serenity-js-playwright-test-template/)
|
|
93
104
|
*/
|
|
94
|
-
export declare const it: TestType<PlaywrightTestArgs & PlaywrightTestOptions &
|
|
105
|
+
export declare const it: TestType<PlaywrightTestArgs & PlaywrightTestOptions & SerenityFixtures, PlaywrightWorkerArgs & PlaywrightWorkerOptions & SerenityWorkerFixtures>;
|
|
95
106
|
/**
|
|
96
107
|
* Declares a single test scenario. Alias for [`it`](https://serenity-js.org/api/playwright-test/function/it/).
|
|
97
108
|
*/
|
|
98
|
-
export declare const test: TestType<PlaywrightTestArgs & PlaywrightTestOptions &
|
|
109
|
+
export declare const test: TestType<PlaywrightTestArgs & PlaywrightTestOptions & SerenityFixtures, PlaywrightWorkerArgs & PlaywrightWorkerOptions & SerenityWorkerFixtures>;
|
|
99
110
|
/**
|
|
100
111
|
* Declares a group of test scenarios.
|
|
101
112
|
*
|
|
@@ -180,23 +191,23 @@ export declare const describe: {
|
|
|
180
191
|
}) => void;
|
|
181
192
|
};
|
|
182
193
|
export declare const beforeAll: {
|
|
183
|
-
(inner: (args: PlaywrightTestArgs & PlaywrightTestOptions &
|
|
184
|
-
(title: string, inner: (args: PlaywrightTestArgs & PlaywrightTestOptions &
|
|
194
|
+
(inner: (args: PlaywrightTestArgs & PlaywrightTestOptions & SerenityFixtures & PlaywrightWorkerArgs & PlaywrightWorkerOptions & SerenityWorkerFixtures, testInfo: TestInfo) => Promise<any> | any): void;
|
|
195
|
+
(title: string, inner: (args: PlaywrightTestArgs & PlaywrightTestOptions & SerenityFixtures & PlaywrightWorkerArgs & PlaywrightWorkerOptions & SerenityWorkerFixtures, testInfo: TestInfo) => Promise<any> | any): void;
|
|
185
196
|
};
|
|
186
197
|
export declare const beforeEach: {
|
|
187
|
-
(inner: (args: PlaywrightTestArgs & PlaywrightTestOptions &
|
|
188
|
-
(title: string, inner: (args: PlaywrightTestArgs & PlaywrightTestOptions &
|
|
198
|
+
(inner: (args: PlaywrightTestArgs & PlaywrightTestOptions & SerenityFixtures & PlaywrightWorkerArgs & PlaywrightWorkerOptions & SerenityWorkerFixtures, testInfo: TestInfo) => Promise<any> | any): void;
|
|
199
|
+
(title: string, inner: (args: PlaywrightTestArgs & PlaywrightTestOptions & SerenityFixtures & PlaywrightWorkerArgs & PlaywrightWorkerOptions & SerenityWorkerFixtures, testInfo: TestInfo) => Promise<any> | any): void;
|
|
189
200
|
};
|
|
190
201
|
export declare const afterEach: {
|
|
191
|
-
(inner: (args: PlaywrightTestArgs & PlaywrightTestOptions &
|
|
192
|
-
(title: string, inner: (args: PlaywrightTestArgs & PlaywrightTestOptions &
|
|
202
|
+
(inner: (args: PlaywrightTestArgs & PlaywrightTestOptions & SerenityFixtures & PlaywrightWorkerArgs & PlaywrightWorkerOptions & SerenityWorkerFixtures, testInfo: TestInfo) => Promise<any> | any): void;
|
|
203
|
+
(title: string, inner: (args: PlaywrightTestArgs & PlaywrightTestOptions & SerenityFixtures & PlaywrightWorkerArgs & PlaywrightWorkerOptions & SerenityWorkerFixtures, testInfo: TestInfo) => Promise<any> | any): void;
|
|
193
204
|
};
|
|
194
205
|
export declare const afterAll: {
|
|
195
|
-
(inner: (args: PlaywrightTestArgs & PlaywrightTestOptions &
|
|
196
|
-
(title: string, inner: (args: PlaywrightTestArgs & PlaywrightTestOptions &
|
|
206
|
+
(inner: (args: PlaywrightTestArgs & PlaywrightTestOptions & SerenityFixtures & PlaywrightWorkerArgs & PlaywrightWorkerOptions & SerenityWorkerFixtures, testInfo: TestInfo) => Promise<any> | any): void;
|
|
207
|
+
(title: string, inner: (args: PlaywrightTestArgs & PlaywrightTestOptions & SerenityFixtures & PlaywrightWorkerArgs & PlaywrightWorkerOptions & SerenityWorkerFixtures, testInfo: TestInfo) => Promise<any> | any): void;
|
|
197
208
|
};
|
|
198
209
|
export declare const expect: Expect;
|
|
199
|
-
export declare const useFixtures: <T extends Record<string, any>, W extends Record<string, any> = object>(customFixtures: Fixtures<T, W, PlaywrightTestArgs & PlaywrightTestOptions &
|
|
210
|
+
export declare const useFixtures: <T extends Record<string, any>, W extends Record<string, any> = object>(customFixtures: Fixtures<T, W, PlaywrightTestArgs & PlaywrightTestOptions & SerenityFixtures, PlaywrightWorkerArgs & PlaywrightWorkerOptions & SerenityWorkerFixtures>) => TestApi<PlaywrightTestArgs & PlaywrightTestOptions & SerenityFixtures & T, PlaywrightWorkerArgs & PlaywrightWorkerOptions & SerenityWorkerFixtures & W>;
|
|
200
211
|
/**
|
|
201
212
|
* Creates a Serenity/JS BDD-style test API around the given Playwright [base test](https://playwright.dev/docs/test-fixtures).
|
|
202
213
|
*
|
|
@@ -335,5 +346,6 @@ export declare const useFixtures: <T extends Record<string, any>, W extends Reco
|
|
|
335
346
|
*
|
|
336
347
|
* @param baseTest
|
|
337
348
|
*/
|
|
338
|
-
export declare function useBase<
|
|
349
|
+
export declare function useBase<BaseTestFixtures extends (PlaywrightTestArgs & PlaywrightTestOptions), BaseWorkerFixtures extends (PlaywrightWorkerArgs & PlaywrightWorkerOptions)>(baseTest: TestType<BaseTestFixtures, BaseWorkerFixtures>): TestApi<BaseTestFixtures & SerenityFixtures, BaseWorkerFixtures & SerenityWorkerFixtures>;
|
|
350
|
+
export {};
|
|
339
351
|
//# sourceMappingURL=test-api.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-api.d.ts","sourceRoot":"","sources":["../../src/api/test-api.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"test-api.d.ts","sourceRoot":"","sources":["../../src/api/test-api.ts"],"names":[],"mappings":"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"}
|