@serenity-js/playwright-test 3.0.0-rc.38 → 3.0.0-rc.40
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 +32 -0
- package/lib/api/PlaywrightTestConfig.d.ts +41 -0
- package/lib/api/PlaywrightTestConfig.d.ts.map +1 -0
- package/lib/{PlaywrightTestConfig.js → api/PlaywrightTestConfig.js} +0 -0
- package/lib/api/PlaywrightTestConfig.js.map +1 -0
- package/lib/api/SerenityFixtures.d.ts +128 -0
- package/lib/api/SerenityFixtures.d.ts.map +1 -0
- package/lib/api/SerenityFixtures.js +3 -0
- package/lib/api/SerenityFixtures.js.map +1 -0
- package/lib/api/SerenityOptions.d.ts +256 -0
- package/lib/api/SerenityOptions.d.ts.map +1 -0
- package/lib/api/SerenityOptions.js +3 -0
- package/lib/api/SerenityOptions.js.map +1 -0
- package/lib/api/SerenityTestType.d.ts +5 -0
- package/lib/api/SerenityTestType.d.ts.map +1 -0
- package/lib/api/SerenityTestType.js +4 -0
- package/lib/api/SerenityTestType.js.map +1 -0
- package/lib/api/index.d.ts +6 -0
- package/lib/api/index.d.ts.map +1 -0
- package/lib/api/index.js +22 -0
- package/lib/api/index.js.map +1 -0
- package/lib/api/test-api.d.ts +115 -0
- package/lib/api/test-api.d.ts.map +1 -0
- package/lib/{api.js → api/test-api.js} +43 -16
- package/lib/api/test-api.js.map +1 -0
- package/lib/index.d.ts +1 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +0 -1
- package/lib/index.js.map +1 -1
- package/lib/reporter/PlaywrightStepReporter.d.ts +3 -0
- package/lib/reporter/PlaywrightStepReporter.d.ts.map +1 -1
- package/lib/reporter/PlaywrightStepReporter.js +55 -12
- package/lib/reporter/PlaywrightStepReporter.js.map +1 -1
- package/lib/reporter/SerenityReporterForPlaywrightTest.d.ts +20 -7
- package/lib/reporter/SerenityReporterForPlaywrightTest.d.ts.map +1 -1
- package/lib/reporter/SerenityReporterForPlaywrightTest.js +4 -8
- package/lib/reporter/SerenityReporterForPlaywrightTest.js.map +1 -1
- package/package.json +6 -5
- package/src/api/PlaywrightTestConfig.ts +42 -0
- package/src/api/SerenityFixtures.ts +130 -0
- package/src/api/SerenityOptions.ts +261 -0
- package/src/api/SerenityTestType.ts +12 -0
- package/src/api/index.ts +5 -0
- package/src/{api.ts → api/test-api.ts} +63 -128
- package/src/index.ts +1 -2
- package/src/reporter/PlaywrightStepReporter.ts +90 -18
- package/src/reporter/SerenityReporterForPlaywrightTest.ts +21 -8
- package/lib/PlaywrightTestConfig.d.ts +0 -8
- package/lib/PlaywrightTestConfig.d.ts.map +0 -1
- package/lib/PlaywrightTestConfig.js.map +0 -1
- package/lib/api.d.ts +0 -213
- package/lib/api.d.ts.map +0 -1
- package/lib/api.js.map +0 -1
- package/src/PlaywrightTestConfig.ts +0 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,38 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [3.0.0-rc.40](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.39...v3.0.0-rc.40) (2023-01-06)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **playwright-test:** corrected invalid import path ([2c46662](https://github.com/serenity-js/serenity-js/commit/2c46662ba37cb43d0a487c265c087114d8dda518))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [3.0.0-rc.39](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.38...v3.0.0-rc.39) (2023-01-05)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* **core:** simplified AsyncOperation events ([ac1a88f](https://github.com/serenity-js/serenity-js/commit/ac1a88f95560b5f163ac3f2302f4274f4bf99455))
|
|
23
|
+
* **core:** simplified internal AsyncOperation events to separate service name from task description ([0162d28](https://github.com/serenity-js/serenity-js/commit/0162d287c84a4ab716e5e655cfc2b816ba89f394))
|
|
24
|
+
* **playwright-test:** better names for screenshots attached to Playwright Test reports ([8c04334](https://github.com/serenity-js/serenity-js/commit/8c043349165a090daf34fb1c363da47003130a53))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### Features
|
|
28
|
+
|
|
29
|
+
* **playwright-test:** annotate Playwright Test reports with Serenity/JS tags ([5e4a513](https://github.com/serenity-js/serenity-js/commit/5e4a513a5cd33cbff459148f365f90847c63518c))
|
|
30
|
+
* **playwright-test:** custom actors can now be defined in playwright config file ([117da34](https://github.com/serenity-js/serenity-js/commit/117da340c0a9bea214b2a3ea8182d803608697dc))
|
|
31
|
+
* **playwright-test:** interoperability between Serenity/JS default `actor` and `page` ([91803de](https://github.com/serenity-js/serenity-js/commit/91803de95c5bd1a8a475e5948e15cc49689a058c))
|
|
32
|
+
* **playwright-test:** support for Photographer and automated screenshots upon activity failure ([c5527ca](https://github.com/serenity-js/serenity-js/commit/c5527caee65cb89014ea9cb28b949cf45d7463a3))
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
6
38
|
# [3.0.0-rc.38](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.37...v3.0.0-rc.38) (2022-12-28)
|
|
7
39
|
|
|
8
40
|
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { PlaywrightTestConfig as BasePlaywrightTestConfig } from '@playwright/test';
|
|
2
|
+
import { SerenityOptions } from './SerenityOptions';
|
|
3
|
+
/**
|
|
4
|
+
* Convenience alias for [PlaywrightTestConfig](https://playwright.dev/docs/test-configuration) object
|
|
5
|
+
* that includes {@apilink SerenityOptions} and allows for any other custom options when needed.
|
|
6
|
+
*
|
|
7
|
+
* #### Example
|
|
8
|
+
* Configuring Playwright Test using the standard `PlaywrightTestConfig` from `@playwright/test`:
|
|
9
|
+
*
|
|
10
|
+
* ```typescript
|
|
11
|
+
* // playwright.config.ts
|
|
12
|
+
* import type { PlaywrightTestConfig } from '@playwright/test'
|
|
13
|
+
* import type { SerenityOptions } from '@serenity-js/playwright-test'
|
|
14
|
+
*
|
|
15
|
+
* const config: PlaywrightTestConfig<SerenityOptions & MyCustomOptions> = {
|
|
16
|
+
* // ...
|
|
17
|
+
* }
|
|
18
|
+
*
|
|
19
|
+
* export default config
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* Simplified configuration using Serenity/JS `PlaywrightTestConfig` from `@serenity-js/playwright-test`:
|
|
23
|
+
*
|
|
24
|
+
* ```typescript
|
|
25
|
+
* // playwright.config.ts
|
|
26
|
+
* import type { PlaywrightTestConfig } from '@serenity-js/playwright-test'
|
|
27
|
+
*
|
|
28
|
+
* const config: PlaywrightTestConfig<MyCustomOptions> = {
|
|
29
|
+
* // ...
|
|
30
|
+
* }
|
|
31
|
+
* export default config
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* #### Learn more
|
|
35
|
+
* - {@apilink SerenityOptions}
|
|
36
|
+
* - {@apilink SerenityFixtures}
|
|
37
|
+
* - {@apilink SerenityReporterForPlaywrightTestConfig}
|
|
38
|
+
* - [Playwright Test configuration](https://playwright.dev/docs/test-configuration)
|
|
39
|
+
*/
|
|
40
|
+
export type PlaywrightTestConfig<TestArgs = object, WorkerArgs = object> = BasePlaywrightTestConfig<SerenityOptions & TestArgs, WorkerArgs>;
|
|
41
|
+
//# sourceMappingURL=PlaywrightTestConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlaywrightTestConfig.d.ts","sourceRoot":"","sources":["../../src/api/PlaywrightTestConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,IAAI,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAEzF,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,MAAM,oBAAoB,CAAC,QAAQ,GAAG,MAAM,EAAE,UAAU,GAAG,MAAM,IAAI,wBAAwB,CAAC,eAAe,GAAG,QAAQ,EAAE,UAAU,CAAC,CAAC"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlaywrightTestConfig.js","sourceRoot":"","sources":["../../src/api/PlaywrightTestConfig.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { Actor, Cast, Serenity } from '@serenity-js/core';
|
|
2
|
+
/**
|
|
3
|
+
* Serenity/JS-specific [Playwright Test fixtures](https://playwright.dev/docs/test-fixtures)
|
|
4
|
+
* injected into your {@apilink it|test scenarios}.
|
|
5
|
+
*
|
|
6
|
+
* ## Example test scenario
|
|
7
|
+
*
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { Ensure, equals } from '@serenity-js/assertions'
|
|
10
|
+
* import { describe, it, test } from '@serenity-js/playwright-test'
|
|
11
|
+
* import { Photographer, TakePhotosOfFailures } from '@serenity-js/web'
|
|
12
|
+
*
|
|
13
|
+
* describe(`Recording items`, () => {
|
|
14
|
+
*
|
|
15
|
+
* test.use({
|
|
16
|
+
* defaultActorName: 'Serena',
|
|
17
|
+
* crew: [
|
|
18
|
+
* Photographer.whoWill(TakePhotosOfFailures),
|
|
19
|
+
* ],
|
|
20
|
+
* })
|
|
21
|
+
*
|
|
22
|
+
* describe(`Todo List App`, () => {
|
|
23
|
+
*
|
|
24
|
+
* it(`should allow me to add a todo item`, async ({ actor }) => {
|
|
25
|
+
* await actor.attemptsTo(
|
|
26
|
+
* startWithAnEmptyList(),
|
|
27
|
+
*
|
|
28
|
+
* recordItem('Buy some milk'),
|
|
29
|
+
*
|
|
30
|
+
* Ensure.that(itemNames(), equals([
|
|
31
|
+
* 'Buy some milk',
|
|
32
|
+
* ])),
|
|
33
|
+
* )
|
|
34
|
+
* })
|
|
35
|
+
* })
|
|
36
|
+
* })
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* ## Learn more
|
|
40
|
+
* - Declaring a Serenity/JS {@apilink it|test scenario}
|
|
41
|
+
* - {@apilink describe|Grouping test scenarios}
|
|
42
|
+
* - [Serenity/JS + Playwright Test project template](https://github.com/serenity-js/serenity-js-playwright-test-template/)
|
|
43
|
+
*/
|
|
44
|
+
export interface SerenityFixtures {
|
|
45
|
+
/**
|
|
46
|
+
* Retrieves the root object of the Serenity/JS framework.
|
|
47
|
+
*/
|
|
48
|
+
serenity: Serenity;
|
|
49
|
+
/**
|
|
50
|
+
* Name and version of the operating system that Playwright Test worker process runs on.
|
|
51
|
+
*/
|
|
52
|
+
platform: {
|
|
53
|
+
name: string;
|
|
54
|
+
version: string;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* A cast of Serenity/JS actors to be used instead of the default cast
|
|
58
|
+
* when instantiating {@apilink SerenityFixtures.actor|actor}
|
|
59
|
+
* and invoking {@apilink SerenityFixtures.actorCalled|actorCalled}.
|
|
60
|
+
*
|
|
61
|
+
* #### Overriding the default cast of Serenity/JS actors
|
|
62
|
+
*
|
|
63
|
+
* ```typescript
|
|
64
|
+
* import { Cast, TakeNotes } from '@serenity-js/core'
|
|
65
|
+
* import { Ensure, equals } from '@serenity-js/assertions'
|
|
66
|
+
* import { BrowseTheWebWithPlaywright } from '@serenity-js/playwright'
|
|
67
|
+
* import { describe, it, test } from '@serenity-js/playwright-test'
|
|
68
|
+
*
|
|
69
|
+
* describe(`Recording items`, () => {
|
|
70
|
+
*
|
|
71
|
+
* test.use({
|
|
72
|
+
* defaultActorName: 'Serena',
|
|
73
|
+
* actors: ({ browser, contextOptions }, use) => {
|
|
74
|
+
* const cast = Cast.whereEveryoneCan(
|
|
75
|
+
* BrowseTheWebWithPlaywright.using(browser, contextOptions),
|
|
76
|
+
* TakeNotes.usingAnEmptyNotepad(),
|
|
77
|
+
* )
|
|
78
|
+
*
|
|
79
|
+
* // Make sure to pass your custom cast to Playwright `use` callback
|
|
80
|
+
* use(cast)
|
|
81
|
+
* },
|
|
82
|
+
* })
|
|
83
|
+
*
|
|
84
|
+
* describe(`Todo List App`, () => {
|
|
85
|
+
*
|
|
86
|
+
* it(`should allow me to add a todo item`, async ({ actor }) => {
|
|
87
|
+
* await actor.attemptsTo(
|
|
88
|
+
* startWithAnEmptyList(),
|
|
89
|
+
*
|
|
90
|
+
* recordItem('Buy some milk'),
|
|
91
|
+
*
|
|
92
|
+
* Ensure.that(itemNames(), equals([
|
|
93
|
+
* 'Buy some milk',
|
|
94
|
+
* ])),
|
|
95
|
+
* )
|
|
96
|
+
* })
|
|
97
|
+
* })
|
|
98
|
+
* })
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
actors: Cast;
|
|
102
|
+
/**
|
|
103
|
+
* Uses the provided {@apilink Cast} of {@apilink SerenityFixtures.actors|actors} to instantiate an {@apilink Actor} called `name`
|
|
104
|
+
* and inject it into a {@apilink it|test scenario}.
|
|
105
|
+
*
|
|
106
|
+
* Retrieves an existing actor if one has already been instantiated.
|
|
107
|
+
*
|
|
108
|
+
* #### Learn more
|
|
109
|
+
* - Declaring a Serenity/JS {@apilink it|test scenario}
|
|
110
|
+
* - {@apilink SerenityOptions.actors}
|
|
111
|
+
* - {@apilink SerenityFixtures.actors}
|
|
112
|
+
*
|
|
113
|
+
* @param name
|
|
114
|
+
*/
|
|
115
|
+
actorCalled: (name: string) => Actor;
|
|
116
|
+
/**
|
|
117
|
+
* Default {@apilink SerenityFixtures.actor|actor} injected into a {@apilink it|test scenario}.
|
|
118
|
+
*
|
|
119
|
+
* Using `actor` fixture is equivalent to invoking {@apilink SerenityFixtures.actorCalled|actorCalled} with {@apilink SerenityOptions.defaultActorName|defaultActorName}.
|
|
120
|
+
*
|
|
121
|
+
* #### Learn more
|
|
122
|
+
* - {@apilink SerenityFixtures.actorCalled|actorCalled}
|
|
123
|
+
* - {@apilink SerenityOptions.defaultActorName}
|
|
124
|
+
* - Declaring a Serenity/JS {@apilink it|test scenario}
|
|
125
|
+
*/
|
|
126
|
+
actor: Actor;
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=SerenityFixtures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SerenityFixtures.d.ts","sourceRoot":"","sources":["../../src/api/SerenityFixtures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,MAAM,WAAW,gBAAgB;IAE7B;;OAEG;IACH,QAAQ,EAAE,QAAQ,CAAC;IAEnB;;OAEG;IACH,QAAQ,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4CG;IACH,MAAM,EAAE,IAAI,CAAC;IAEb;;;;;;;;;;;;OAYG;IACH,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,KAAK,CAAC;IAErC;;;;;;;;;OASG;IACH,KAAK,EAAE,KAAK,CAAC;CAChB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SerenityFixtures.js","sourceRoot":"","sources":["../../src/api/SerenityFixtures.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { PlaywrightTestOptions, PlaywrightWorkerArgs, TestFixture } from '@playwright/test';
|
|
2
|
+
import { Cast, ClassDescription, Duration, StageCrewMember, StageCrewMemberBuilder } from '@serenity-js/core';
|
|
3
|
+
import { PlaywrightOptions } from '@serenity-js/playwright';
|
|
4
|
+
/**
|
|
5
|
+
* Configuration object accepted by `@serenity-js/playwright-test`.
|
|
6
|
+
*
|
|
7
|
+
* ## Example
|
|
8
|
+
*
|
|
9
|
+
* ```typescript
|
|
10
|
+
* // playwright.config.ts
|
|
11
|
+
* import type { Cast, TakeNotes } from '@serenity-js/core'
|
|
12
|
+
* import type { BrowseTheWebWithPlaywright } from '@serenity-js/playwright'
|
|
13
|
+
* import type { PlaywrightTestConfig } from '@serenity-js/playwright-test'
|
|
14
|
+
* import type { CallAnApi } from '@serenity-js/rest'
|
|
15
|
+
*
|
|
16
|
+
* // Define any custom configuration options, if needed
|
|
17
|
+
* interface MyCustomOptions {
|
|
18
|
+
* apiUrl: string;
|
|
19
|
+
* }
|
|
20
|
+
*
|
|
21
|
+
* const config: PlaywrightTestConfig<MyCustomOptions> = {
|
|
22
|
+
*
|
|
23
|
+
* // Register Serenity/JS reporter for Playwright Test
|
|
24
|
+
* // to enable integration with Serenity/JS stage crew members
|
|
25
|
+
* // and have them instantiated in the Playwright reporter process
|
|
26
|
+
* reporter: [
|
|
27
|
+
* [ '@serenity-js/playwright-test', {
|
|
28
|
+
* // Stage crew members instantiated in the test reporter process
|
|
29
|
+
* crew: [
|
|
30
|
+
* '@serenity-js/serenity-bdd',
|
|
31
|
+
* '@serenity-js/console-reporter',
|
|
32
|
+
* [ '@serenity-js/core:ArtifactArchiver', { outputDirectory: 'target/site/serenity' } ],
|
|
33
|
+
* ]
|
|
34
|
+
* }]
|
|
35
|
+
* ],
|
|
36
|
+
*
|
|
37
|
+
* use: {
|
|
38
|
+
*
|
|
39
|
+
* // Register Serenity/JS stage crew members
|
|
40
|
+
* // and have them instantiated in Playwright Test worker processes
|
|
41
|
+
* crew: [
|
|
42
|
+
* [ '@serenity-js/web:Photographer', { strategy: 'TakePhotosOfFailures' } ]
|
|
43
|
+
* ],
|
|
44
|
+
*
|
|
45
|
+
* // Register a custom cast of Serenity/JS actors
|
|
46
|
+
* // if you don't want to use the default one
|
|
47
|
+
* actors: ({ browser, contextOptions, apiUrl }, use) => {
|
|
48
|
+
* const cast = Cast.whereEveryoneCan(
|
|
49
|
+
* BrowseTheWebWithPlaywright.using(browser, contextOptions),
|
|
50
|
+
* TakeNotes.usingAnEmptyNotepad(),
|
|
51
|
+
* CallAnApi.at(apiUrl),
|
|
52
|
+
* )
|
|
53
|
+
*
|
|
54
|
+
* use(cast)
|
|
55
|
+
* },
|
|
56
|
+
*
|
|
57
|
+
* // Name to be given to an actor injected via `actor` fixture
|
|
58
|
+
* defaultActorName: 'Alice',
|
|
59
|
+
*
|
|
60
|
+
* // Any custom options, as per the MyCustomOptions interface
|
|
61
|
+
* apiUrl: 'https://api.serenity-js.org/v1'
|
|
62
|
+
*
|
|
63
|
+
* // Any other Playwright options
|
|
64
|
+
* baseURL: 'https://todo-app.serenity-js.org/',
|
|
65
|
+
* video: 'on-first-retry',
|
|
66
|
+
* trace: 'on-first-retry',
|
|
67
|
+
* },
|
|
68
|
+
* }
|
|
69
|
+
*
|
|
70
|
+
* export default config
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* ## Learn more
|
|
74
|
+
* - {@apilink PlaywrightTestConfig}
|
|
75
|
+
* - {@apilink Cast}
|
|
76
|
+
* - {@apilink SerenityFixtures}
|
|
77
|
+
*/
|
|
78
|
+
export interface SerenityOptions {
|
|
79
|
+
/**
|
|
80
|
+
* Configures the {@apilink Cast} of {@apilink SerenityConfig.actors|actors} to be used when injecting an {@apilink SerenityFixtures.actor|actor}
|
|
81
|
+
* or invoking {@apilink SerenityFixtures.actorCalled|actorCalled} in a {@apilink it|test scenario}.
|
|
82
|
+
*
|
|
83
|
+
* :::info Did you know?
|
|
84
|
+
* When you use `@serenity-js/playwright-test` {@apilink it|test APIs}, Serenity/JS already provides a default cast of actors for you.
|
|
85
|
+
* Each one of the default actors receives {@apilink Ability|abilities} to {@apilink BrowseTheWebWithPlaywright} and {@apilink TakeNotes.usingAnEmptyNotepad}.
|
|
86
|
+
*
|
|
87
|
+
* The default abilities should be sufficient in most web testing scenarios. However, you might want to override this default configuration
|
|
88
|
+
* when you need your actors to {@apilink CallAnApi|interact with REST APIs}, {@apilink ManageALocalServer|manage local servers},
|
|
89
|
+
* start with a notepad that has some {@apilink TakeNotes.using|initial state}, or receive {@apilink Ability|custom abilities}.
|
|
90
|
+
* :::
|
|
91
|
+
*
|
|
92
|
+
* #### Using a custom crew of Serenity/JS actors
|
|
93
|
+
*
|
|
94
|
+
* ```typescript
|
|
95
|
+
* // playwright.config.ts
|
|
96
|
+
* import type { PlaywrightTestConfig } from '@serenity-js/playwright-test'
|
|
97
|
+
* import { Cast, TakeNotes } from '@serenity-js/core'
|
|
98
|
+
* import { BrowseTheWebWithPlaywright } from '@serenity-js/playwright'
|
|
99
|
+
* import { CallAnApi } from '@serenity-js/rest'
|
|
100
|
+
*
|
|
101
|
+
* // Define any custom configuration options, if needed
|
|
102
|
+
* interface MyCustomOptions {
|
|
103
|
+
* apiUrl: string;
|
|
104
|
+
* }
|
|
105
|
+
*
|
|
106
|
+
* // Parameterise PlaywrightTestConfig with MyCustomOptions
|
|
107
|
+
* // to enable type checking of any custom properties
|
|
108
|
+
* const config: PlaywrightTestConfig<MyCustomOptions> = {
|
|
109
|
+
* use: {
|
|
110
|
+
* contextOptions: {
|
|
111
|
+
* defaultNavigationTimeout: 30_000,
|
|
112
|
+
* },
|
|
113
|
+
*
|
|
114
|
+
* // custom properties
|
|
115
|
+
* apiUrl: 'https://api.serenity-js.org/v1',
|
|
116
|
+
*
|
|
117
|
+
* // Custom cast of actors receives `contextOptions`
|
|
118
|
+
* // with the additional Serenity/JS properties (see `PlaywrightOptions`),
|
|
119
|
+
* // as well as any other custom properties you define in the destructuring expression,
|
|
120
|
+
* // such as `apiUrl`.
|
|
121
|
+
* actors: ({ browser, contextOptions, apiUrl }, use) => {
|
|
122
|
+
* const cast = Cast.whereEveryoneCan(
|
|
123
|
+
* BrowseTheWebWithPlaywright.using(browser, contextOptions),
|
|
124
|
+
* TakeNotes.usingAnEmptyNotepad(),
|
|
125
|
+
* CallAnApi.at(apiUrl),
|
|
126
|
+
* )
|
|
127
|
+
*
|
|
128
|
+
* // Make sure to pass your custom cast to Playwright `use` callback
|
|
129
|
+
* use(cast)
|
|
130
|
+
* },
|
|
131
|
+
* },
|
|
132
|
+
* };
|
|
133
|
+
* export default config
|
|
134
|
+
* ```
|
|
135
|
+
*
|
|
136
|
+
* #### Learn more
|
|
137
|
+
* - Declaring a Serenity/JS {@apilink it|test scenario}
|
|
138
|
+
* - {@apilink SerenityFixtures}
|
|
139
|
+
*/
|
|
140
|
+
actors: TestFixture<Cast, PlaywrightTestOptions & PlaywrightWorkerArgs>;
|
|
141
|
+
/**
|
|
142
|
+
* Configures the name given to the default Serenity/JS {@apilink SerenityFixtures.actor|actor}
|
|
143
|
+
* injected into a {@apilink it|test scenario}.
|
|
144
|
+
*
|
|
145
|
+
* #### Learn more
|
|
146
|
+
* - Declaring a Serenity/JS {@apilink it|test scenario}
|
|
147
|
+
* - {@apilink SerenityFixtures}
|
|
148
|
+
*/
|
|
149
|
+
defaultActorName: string;
|
|
150
|
+
/**
|
|
151
|
+
* Configures the {@apilink SerenityConfig.crew|stage crew members}
|
|
152
|
+
* to be instantiated in Playwright Test worker processes.
|
|
153
|
+
*
|
|
154
|
+
* :::info Did you know?
|
|
155
|
+
* By default, Serenity/JS registers a {@apilink Photographer}.whoWill({@apilink TakePhotosOfFailures}),
|
|
156
|
+
* so that any test failures are automatically accompanied by a screenshot.
|
|
157
|
+
*
|
|
158
|
+
* If you prefer a different behaviour, you can configure the `crew` with an empty array to disable taking screenshots altogether (`crew: []`),
|
|
159
|
+
* or with a {@apilink Photographer} who uses a different {@apilink PhotoTakingStrategy}, like to {@apilink TakePhotosOfInteractions}.
|
|
160
|
+
* :::
|
|
161
|
+
*
|
|
162
|
+
* #### Example
|
|
163
|
+
*
|
|
164
|
+
* ```typescript
|
|
165
|
+
* // playwright.config.ts
|
|
166
|
+
* import type { PlaywrightTestConfig } from '@serenity-js/playwright-test'
|
|
167
|
+
*
|
|
168
|
+
* const config: PlaywrightTestConfig = {
|
|
169
|
+
* use: {
|
|
170
|
+
* crew: [
|
|
171
|
+
* [ '@serenity-js/web:Photographer', { strategy: 'TakePhotosOfFailures' } ]
|
|
172
|
+
* ],
|
|
173
|
+
* },
|
|
174
|
+
* };
|
|
175
|
+
* export default config
|
|
176
|
+
* ```
|
|
177
|
+
*
|
|
178
|
+
* #### Learn more
|
|
179
|
+
* - {@apilink SerenityConfig.crew}
|
|
180
|
+
*/
|
|
181
|
+
crew: Array<ClassDescription | StageCrewMember | StageCrewMemberBuilder>;
|
|
182
|
+
/**
|
|
183
|
+
* Sets the {@apilink SerenityConfig.cueTimeout|cueTimeout} to a given {@apilink Duration|duration} or a numeric value in milliseconds.
|
|
184
|
+
* Defaults to **5 seconds**.
|
|
185
|
+
*
|
|
186
|
+
* #### Learn more
|
|
187
|
+
* - {@apilink SerenityConfig.cueTimeout}
|
|
188
|
+
* - {@apilink Discardable}
|
|
189
|
+
* - {@apilink Ability}
|
|
190
|
+
*/
|
|
191
|
+
cueTimeout: number | Duration;
|
|
192
|
+
/**
|
|
193
|
+
* Playwright [BrowserContextOptions](https://playwright.dev/docs/api/class-testoptions#test-options-context-options),
|
|
194
|
+
* augmented with several convenience properties to be used with the {@apilink Ability|ability} to {@apilink BrowseTheWebWithPlaywright}.
|
|
195
|
+
*
|
|
196
|
+
* Additional convenience properties include:
|
|
197
|
+
* - {@apilink PlaywrightOptions.defaultNavigationTimeout}
|
|
198
|
+
* - {@apilink PlaywrightOptions.defaultNavigationWaitUntil}
|
|
199
|
+
* - {@apilink PlaywrightOptions.defaultTimeout}
|
|
200
|
+
*
|
|
201
|
+
* #### Using `contextOptions` with the default cast of Serenity/JS actors
|
|
202
|
+
*
|
|
203
|
+
* ```typescript
|
|
204
|
+
* // playwright.config.ts
|
|
205
|
+
* import type { PlaywrightTestConfig } from '@serenity-js/playwright-test'
|
|
206
|
+
*
|
|
207
|
+
* const config: PlaywrightTestConfig = {
|
|
208
|
+
* use: {
|
|
209
|
+
* contextOptions: {
|
|
210
|
+
* defaultNavigationTimeout: 30_000,
|
|
211
|
+
* }
|
|
212
|
+
*
|
|
213
|
+
* // Since `actors` property is not defined,
|
|
214
|
+
* // `contextOptions` will be passed to the default cast of Serenity/JS actors
|
|
215
|
+
* // and injected into the ability to `BrowseTheWebWithPlaywright`
|
|
216
|
+
* // that each actor receives.
|
|
217
|
+
* },
|
|
218
|
+
* };
|
|
219
|
+
* export default config;
|
|
220
|
+
* ```
|
|
221
|
+
*
|
|
222
|
+
* #### Using `contextOptions` with a custom cast of Serenity/JS actors
|
|
223
|
+
*
|
|
224
|
+
* ```typescript
|
|
225
|
+
* // playwright.config.ts
|
|
226
|
+
* import type { PlaywrightTestConfig } from '@serenity-js/playwright-test'
|
|
227
|
+
*
|
|
228
|
+
* const config: PlaywrightTestConfig = {
|
|
229
|
+
* use: {
|
|
230
|
+
* contextOptions: {
|
|
231
|
+
* defaultNavigationTimeout: 30_000,
|
|
232
|
+
* }
|
|
233
|
+
*
|
|
234
|
+
* // Custom cast of actors receives `contextOptions` with the
|
|
235
|
+
* // additional Serenity/JS properties.
|
|
236
|
+
* actors: ({ browser, contextOptions }, use) => {
|
|
237
|
+
* const cast = Cast.whereEveryoneCan(
|
|
238
|
+
* BrowseTheWebWithPlaywright.using(browser, contextOptions),
|
|
239
|
+
* TakeNotes.usingAnEmptyNotepad(),
|
|
240
|
+
* )
|
|
241
|
+
*
|
|
242
|
+
* use(cast)
|
|
243
|
+
* },
|
|
244
|
+
* },
|
|
245
|
+
* };
|
|
246
|
+
* export default config;
|
|
247
|
+
* ```
|
|
248
|
+
*
|
|
249
|
+
* #### Learn more
|
|
250
|
+
* - {@apilink SerenityFixtures}
|
|
251
|
+
* - [Playwright Browser Context options](https://playwright.dev/docs/api/class-testoptions#test-options-context-options)
|
|
252
|
+
* - [Playwright Test fixtures](https://playwright.dev/docs/test-fixtures)
|
|
253
|
+
*/
|
|
254
|
+
contextOptions: PlaywrightOptions;
|
|
255
|
+
}
|
|
256
|
+
//# sourceMappingURL=SerenityOptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SerenityOptions.d.ts","sourceRoot":"","sources":["../../src/api/SerenityOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC5F,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,QAAQ,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC9G,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyEG;AACH,MAAM,WAAW,eAAe;IAE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4DG;IACH,MAAM,EAAE,WAAW,CAAC,IAAI,EAAE,qBAAqB,GAAG,oBAAoB,CAAC,CAAA;IAEvE;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6DG;IACH,cAAc,EAAE,iBAAiB,CAAC;CACrC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SerenityOptions.js","sourceRoot":"","sources":["../../src/api/SerenityOptions.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions, TestType } from '@playwright/test';
|
|
2
|
+
import { SerenityFixtures } from './SerenityFixtures';
|
|
3
|
+
import { SerenityOptions } from './SerenityOptions';
|
|
4
|
+
export type SerenityTestType = TestType<PlaywrightTestArgs & PlaywrightTestOptions & Omit<SerenityOptions, 'actors'> & SerenityFixtures, PlaywrightWorkerArgs & PlaywrightWorkerOptions>;
|
|
5
|
+
//# sourceMappingURL=SerenityTestType.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SerenityTestType.d.ts","sourceRoot":"","sources":["../../src/api/SerenityTestType.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEtI,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD,MAAM,MAAM,gBAAgB,GACxB,QAAQ,CACJ,kBAAkB,GAAG,qBAAqB,GAAG,IAAI,CAAC,eAAe,EAAE,QAAQ,CAAC,GAAG,gBAAgB,EAC/F,oBAAoB,GAAG,uBAAuB,CACjD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SerenityTestType.js","sourceRoot":"","sources":["../../src/api/SerenityTestType.ts"],"names":[],"mappings":";;AAWA,6CAA6C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC"}
|
package/lib/api/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./PlaywrightTestConfig"), exports);
|
|
18
|
+
__exportStar(require("./SerenityFixtures"), exports);
|
|
19
|
+
__exportStar(require("./SerenityOptions"), exports);
|
|
20
|
+
__exportStar(require("./SerenityTestType"), exports);
|
|
21
|
+
__exportStar(require("./test-api"), exports);
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAAuC;AACvC,qDAAmC;AACnC,oDAAkC;AAClC,qDAAmC;AACnC,6CAA2B"}
|