@serenity-js/playwright-test 3.0.0-rc.37 → 3.0.0-rc.38
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 +11 -0
- package/lib/api.d.ts +190 -2
- package/lib/api.d.ts.map +1 -1
- package/lib/api.js +105 -0
- package/lib/api.js.map +1 -1
- package/lib/reporter/PlaywrightStepReporter.d.ts.map +1 -1
- package/lib/reporter/PlaywrightStepReporter.js +1 -1
- package/lib/reporter/PlaywrightStepReporter.js.map +1 -1
- package/lib/reporter/SerenityReporterForPlaywrightTest.d.ts +2 -2
- package/lib/reporter/SerenityReporterForPlaywrightTest.d.ts.map +1 -1
- package/package.json +5 -7
- package/src/api.ts +198 -2
- package/src/reporter/PlaywrightStepReporter.ts +7 -7
- package/src/reporter/SerenityReporterForPlaywrightTest.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
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.38](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.37...v3.0.0-rc.38) (2022-12-28)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **playwright:** introduced an explicit dependency on Playwright ([2136132](https://github.com/serenity-js/serenity-js/commit/2136132a95bfb4181c4854291cfeeacb876b9cfb))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [3.0.0-rc.37](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.36...v3.0.0-rc.37) (2022-12-18)
|
|
7
18
|
|
|
8
19
|
|
package/lib/api.d.ts
CHANGED
|
@@ -1,21 +1,209 @@
|
|
|
1
1
|
import { PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions, TestType } from '@playwright/test';
|
|
2
|
-
import { Actor, Cast, Duration, Serenity,
|
|
3
|
-
|
|
2
|
+
import { Actor, Cast, Duration, Serenity, StageCrewMember } from '@serenity-js/core';
|
|
3
|
+
/**
|
|
4
|
+
* Serenity/JS-specific [Playwright Test fixtures](https://playwright.dev/docs/test-fixtures).
|
|
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 test scenario using {@apilink it}
|
|
41
|
+
* - Grouping test scenarios using {@apilink describe}
|
|
42
|
+
* - [Serenity/JS + Playwright Test project template](https://github.com/serenity-js/serenity-js-playwright-test-template/)
|
|
43
|
+
*/
|
|
44
|
+
export interface SerenityFixtures {
|
|
45
|
+
/**
|
|
46
|
+
* Configures the {@apilink Cast} of {@apilink SerenityConfig.actors|actors} to be used when injecting an {@apilink SerenityFixtures.actor|actor}
|
|
47
|
+
* or invoking {@apilink SerenityFixtures.actorCalled|actorCalled} in a {@apilink it|test scenario}.
|
|
48
|
+
*
|
|
49
|
+
* #### Learn more
|
|
50
|
+
* - Declaring a test scenario using {@apilink it}
|
|
51
|
+
*/
|
|
4
52
|
actors: Cast;
|
|
53
|
+
/**
|
|
54
|
+
* Configures the {@apilink SerenityConfig.crew|stage crew}
|
|
55
|
+
*/
|
|
5
56
|
crew: StageCrewMember[];
|
|
57
|
+
/**
|
|
58
|
+
* Configures the {@apilink SerenityConfig.cueTimeout|cueTimeout}
|
|
59
|
+
*/
|
|
6
60
|
cueTimeout: Duration;
|
|
61
|
+
/**
|
|
62
|
+
* Retrieves the root object of the Serenity/JS framework.
|
|
63
|
+
*/
|
|
7
64
|
serenity: Serenity;
|
|
65
|
+
/**
|
|
66
|
+
* Name and version of the operating system the Playwright Test runs on.
|
|
67
|
+
*/
|
|
8
68
|
platform: {
|
|
9
69
|
name: string;
|
|
10
70
|
version: string;
|
|
11
71
|
};
|
|
72
|
+
/**
|
|
73
|
+
* Uses the provided {@apilink Cast} of {@apilink SerenityFixtures.actors|actors} to instantiate an {@apilink Actor} called `name`
|
|
74
|
+
* and inject it into a {@apilink it|test scenario}.
|
|
75
|
+
* Retrieves an existing actor if one has already been instantiated.
|
|
76
|
+
*
|
|
77
|
+
* #### Learn more
|
|
78
|
+
* - Declaring a test scenario using {@apilink it}
|
|
79
|
+
*
|
|
80
|
+
* @param name
|
|
81
|
+
*/
|
|
12
82
|
actorCalled: (name: string) => Actor;
|
|
83
|
+
/**
|
|
84
|
+
* Configures the name given to the default {@apilink SerenityFixtures.actor|actor} injected into the {@apilink it|test scenario}.
|
|
85
|
+
*
|
|
86
|
+
* #### Learn more
|
|
87
|
+
* - Declaring a test scenario using {@apilink it}
|
|
88
|
+
*/
|
|
13
89
|
defaultActorName: string;
|
|
90
|
+
/**
|
|
91
|
+
* Default {@apilink SerenityFixtures.actor|actor} injected into a {@apilink it|test scenario}.
|
|
92
|
+
*
|
|
93
|
+
* #### Learn more
|
|
94
|
+
* - {@apilink SerenityFixtures.actorCalled|actorCalled}
|
|
95
|
+
* - Declaring a test scenario using {@apilink it}
|
|
96
|
+
*/
|
|
14
97
|
actor: Actor;
|
|
15
98
|
}
|
|
16
99
|
export type SerenityTestType = TestType<PlaywrightTestArgs & PlaywrightTestOptions & SerenityFixtures, PlaywrightWorkerArgs & PlaywrightWorkerOptions>;
|
|
100
|
+
/**
|
|
101
|
+
* Declares a single test scenario.
|
|
102
|
+
*
|
|
103
|
+
* ## Example
|
|
104
|
+
*
|
|
105
|
+
* ```typescript
|
|
106
|
+
* import { Ensure, equals } from '@serenity-js/assertions'
|
|
107
|
+
* import { describe, it } from '@serenity-js/playwright-test'
|
|
108
|
+
*
|
|
109
|
+
* describe(`Todo List App`, () => {
|
|
110
|
+
*
|
|
111
|
+
* it(`should allow me to add a todo item`, async ({ actor }) => {
|
|
112
|
+
* await actor.attemptsTo(
|
|
113
|
+
* startWithAnEmptyList(),
|
|
114
|
+
*
|
|
115
|
+
* recordItem('Buy some milk'),
|
|
116
|
+
*
|
|
117
|
+
* Ensure.that(itemNames(), equals([
|
|
118
|
+
* 'Buy some milk',
|
|
119
|
+
* ])),
|
|
120
|
+
* )
|
|
121
|
+
* })
|
|
122
|
+
*
|
|
123
|
+
* it('supports multiple actors using separate browsers', async ({ actorCalled }) => {
|
|
124
|
+
* await actorCalled('Alice').attemptsTo(
|
|
125
|
+
* startWithAListContaining(
|
|
126
|
+
* 'Feed the cat'
|
|
127
|
+
* ),
|
|
128
|
+
* )
|
|
129
|
+
*
|
|
130
|
+
* await actorCalled('Bob').attemptsTo(
|
|
131
|
+
* startWithAListContaining(
|
|
132
|
+
* 'Walk the dog'
|
|
133
|
+
* ),
|
|
134
|
+
* )
|
|
135
|
+
*
|
|
136
|
+
* await actorCalled('Alice').attemptsTo(
|
|
137
|
+
* Ensure.that(itemNames(), equals([
|
|
138
|
+
* 'Feed the cat'
|
|
139
|
+
* ])),
|
|
140
|
+
* )
|
|
141
|
+
*
|
|
142
|
+
* await actorCalled('Bob').attemptsTo(
|
|
143
|
+
* Ensure.that(itemNames(), equals([
|
|
144
|
+
* 'Walk the dog'
|
|
145
|
+
* ])),
|
|
146
|
+
* )
|
|
147
|
+
* })
|
|
148
|
+
* })
|
|
149
|
+
* ```
|
|
150
|
+
*
|
|
151
|
+
* ## Learn more
|
|
152
|
+
* - Grouping test scenarios using {@apilink describe}
|
|
153
|
+
* - {@apilink SerenityFixtures}
|
|
154
|
+
* - [Playwright Test `test` function](https://playwright.dev/docs/api/class-test#test-call)
|
|
155
|
+
* - [Serenity/JS + Playwright Test project template](https://github.com/serenity-js/serenity-js-playwright-test-template/)
|
|
156
|
+
*/
|
|
17
157
|
export declare const it: SerenityTestType;
|
|
18
158
|
export declare const test: SerenityTestType;
|
|
159
|
+
/**
|
|
160
|
+
* Declares a group of test scenarios.
|
|
161
|
+
*
|
|
162
|
+
* ## Example
|
|
163
|
+
*
|
|
164
|
+
* ```typescript
|
|
165
|
+
* import { Ensure, equals } from '@serenity-js/assertions'
|
|
166
|
+
* import { describe, it, test } from '@serenity-js/playwright-test'
|
|
167
|
+
* import { Photographer, TakePhotosOfFailures, Value } from '@serenity-js/web'
|
|
168
|
+
*
|
|
169
|
+
* describe(`Todo List App`, () => {
|
|
170
|
+
*
|
|
171
|
+
* test.use({
|
|
172
|
+
* defaultActorName: 'Serena',
|
|
173
|
+
* crew: [
|
|
174
|
+
* Photographer.whoWill(TakePhotosOfFailures),
|
|
175
|
+
* ],
|
|
176
|
+
* })
|
|
177
|
+
*
|
|
178
|
+
* it(`should allow me to add a todo item`, async ({ actor }) => {
|
|
179
|
+
* await actor.attemptsTo(
|
|
180
|
+
* startWithAnEmptyList(),
|
|
181
|
+
*
|
|
182
|
+
* recordItem('Buy some milk'),
|
|
183
|
+
*
|
|
184
|
+
* Ensure.that(itemNames(), equals([
|
|
185
|
+
* 'Buy some milk',
|
|
186
|
+
* ])),
|
|
187
|
+
* )
|
|
188
|
+
* })
|
|
189
|
+
*
|
|
190
|
+
* it('should clear text input field when an item is added', async ({ actor }) => {
|
|
191
|
+
* await actor.attemptsTo(
|
|
192
|
+
* startWithAnEmptyList(),
|
|
193
|
+
*
|
|
194
|
+
* recordItem('Buy some milk'),
|
|
195
|
+
*
|
|
196
|
+
* Ensure.that(Value.of(newTodoInput()), equals('')),
|
|
197
|
+
* )
|
|
198
|
+
* })
|
|
199
|
+
* })
|
|
200
|
+
* ```
|
|
201
|
+
*
|
|
202
|
+
* ## Learn more
|
|
203
|
+
* - Declaring a test scenario using {@apilink it}
|
|
204
|
+
* - [Playwright Test `describe` function](https://playwright.dev/docs/api/class-test#test-describe-1)
|
|
205
|
+
* - [Serenity/JS + Playwright Test project template](https://github.com/serenity-js/serenity-js-playwright-test-template/)
|
|
206
|
+
*/
|
|
19
207
|
export declare const describe: SerenityTestType['describe'];
|
|
20
208
|
export declare const beforeAll: SerenityTestType['beforeAll'];
|
|
21
209
|
export declare const beforeEach: SerenityTestType['beforeEach'];
|
package/lib/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,uBAAuB,EAA0B,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC9J,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAgC,
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,uBAAuB,EAA0B,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC9J,O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,gBAAgB,CAAC,WAAW,CAAgB,CAAC;AACrE,eAAO,MAAM,QAAQ,EAAE,gBAAgB,CAAC,UAAU,CAAe,CAAC;AAClE,eAAO,MAAM,MAAM,EAAE,gBAAgB,CAAC,QAAQ,CAAa,CAAC"}
|
package/lib/api.js
CHANGED
|
@@ -31,6 +31,63 @@ const model_1 = require("@serenity-js/core/lib/model");
|
|
|
31
31
|
const playwright_1 = require("@serenity-js/playwright");
|
|
32
32
|
const os = __importStar(require("os"));
|
|
33
33
|
const reporter_1 = require("./reporter");
|
|
34
|
+
/**
|
|
35
|
+
* Declares a single test scenario.
|
|
36
|
+
*
|
|
37
|
+
* ## Example
|
|
38
|
+
*
|
|
39
|
+
* ```typescript
|
|
40
|
+
* import { Ensure, equals } from '@serenity-js/assertions'
|
|
41
|
+
* import { describe, it } from '@serenity-js/playwright-test'
|
|
42
|
+
*
|
|
43
|
+
* describe(`Todo List App`, () => {
|
|
44
|
+
*
|
|
45
|
+
* it(`should allow me to add a todo item`, async ({ actor }) => {
|
|
46
|
+
* await actor.attemptsTo(
|
|
47
|
+
* startWithAnEmptyList(),
|
|
48
|
+
*
|
|
49
|
+
* recordItem('Buy some milk'),
|
|
50
|
+
*
|
|
51
|
+
* Ensure.that(itemNames(), equals([
|
|
52
|
+
* 'Buy some milk',
|
|
53
|
+
* ])),
|
|
54
|
+
* )
|
|
55
|
+
* })
|
|
56
|
+
*
|
|
57
|
+
* it('supports multiple actors using separate browsers', async ({ actorCalled }) => {
|
|
58
|
+
* await actorCalled('Alice').attemptsTo(
|
|
59
|
+
* startWithAListContaining(
|
|
60
|
+
* 'Feed the cat'
|
|
61
|
+
* ),
|
|
62
|
+
* )
|
|
63
|
+
*
|
|
64
|
+
* await actorCalled('Bob').attemptsTo(
|
|
65
|
+
* startWithAListContaining(
|
|
66
|
+
* 'Walk the dog'
|
|
67
|
+
* ),
|
|
68
|
+
* )
|
|
69
|
+
*
|
|
70
|
+
* await actorCalled('Alice').attemptsTo(
|
|
71
|
+
* Ensure.that(itemNames(), equals([
|
|
72
|
+
* 'Feed the cat'
|
|
73
|
+
* ])),
|
|
74
|
+
* )
|
|
75
|
+
*
|
|
76
|
+
* await actorCalled('Bob').attemptsTo(
|
|
77
|
+
* Ensure.that(itemNames(), equals([
|
|
78
|
+
* 'Walk the dog'
|
|
79
|
+
* ])),
|
|
80
|
+
* )
|
|
81
|
+
* })
|
|
82
|
+
* })
|
|
83
|
+
* ```
|
|
84
|
+
*
|
|
85
|
+
* ## Learn more
|
|
86
|
+
* - Grouping test scenarios using {@apilink describe}
|
|
87
|
+
* - {@apilink SerenityFixtures}
|
|
88
|
+
* - [Playwright Test `test` function](https://playwright.dev/docs/api/class-test#test-call)
|
|
89
|
+
* - [Serenity/JS + Playwright Test project template](https://github.com/serenity-js/serenity-js-playwright-test-template/)
|
|
90
|
+
*/
|
|
34
91
|
exports.it = test_1.test.extend({
|
|
35
92
|
cueTimeout: core_1.Duration.ofSeconds(5),
|
|
36
93
|
crew: [],
|
|
@@ -88,6 +145,54 @@ exports.it = test_1.test.extend({
|
|
|
88
145
|
},
|
|
89
146
|
});
|
|
90
147
|
exports.test = exports.it;
|
|
148
|
+
/**
|
|
149
|
+
* Declares a group of test scenarios.
|
|
150
|
+
*
|
|
151
|
+
* ## Example
|
|
152
|
+
*
|
|
153
|
+
* ```typescript
|
|
154
|
+
* import { Ensure, equals } from '@serenity-js/assertions'
|
|
155
|
+
* import { describe, it, test } from '@serenity-js/playwright-test'
|
|
156
|
+
* import { Photographer, TakePhotosOfFailures, Value } from '@serenity-js/web'
|
|
157
|
+
*
|
|
158
|
+
* describe(`Todo List App`, () => {
|
|
159
|
+
*
|
|
160
|
+
* test.use({
|
|
161
|
+
* defaultActorName: 'Serena',
|
|
162
|
+
* crew: [
|
|
163
|
+
* Photographer.whoWill(TakePhotosOfFailures),
|
|
164
|
+
* ],
|
|
165
|
+
* })
|
|
166
|
+
*
|
|
167
|
+
* it(`should allow me to add a todo item`, async ({ actor }) => {
|
|
168
|
+
* await actor.attemptsTo(
|
|
169
|
+
* startWithAnEmptyList(),
|
|
170
|
+
*
|
|
171
|
+
* recordItem('Buy some milk'),
|
|
172
|
+
*
|
|
173
|
+
* Ensure.that(itemNames(), equals([
|
|
174
|
+
* 'Buy some milk',
|
|
175
|
+
* ])),
|
|
176
|
+
* )
|
|
177
|
+
* })
|
|
178
|
+
*
|
|
179
|
+
* it('should clear text input field when an item is added', async ({ actor }) => {
|
|
180
|
+
* await actor.attemptsTo(
|
|
181
|
+
* startWithAnEmptyList(),
|
|
182
|
+
*
|
|
183
|
+
* recordItem('Buy some milk'),
|
|
184
|
+
*
|
|
185
|
+
* Ensure.that(Value.of(newTodoInput()), equals('')),
|
|
186
|
+
* )
|
|
187
|
+
* })
|
|
188
|
+
* })
|
|
189
|
+
* ```
|
|
190
|
+
*
|
|
191
|
+
* ## Learn more
|
|
192
|
+
* - Declaring a test scenario using {@apilink it}
|
|
193
|
+
* - [Playwright Test `describe` function](https://playwright.dev/docs/api/class-test#test-describe-1)
|
|
194
|
+
* - [Serenity/JS + Playwright Test project template](https://github.com/serenity-js/serenity-js-playwright-test-template/)
|
|
195
|
+
*/
|
|
91
196
|
exports.describe = exports.it.describe;
|
|
92
197
|
exports.beforeAll = exports.it.beforeAll;
|
|
93
198
|
exports.beforeEach = exports.it.beforeEach;
|
package/lib/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA8J;AAC9J,
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA8J;AAC9J,4CAAmH;AACnH,yDAA0E;AAC1E,uDAAsE;AACtE,wDAAqE;AACrE,uCAAyB;AAGzB,yCAA0H;AAyG1H;;;;;;;;;;;;;;;;;;;;;;;;;;;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ot":"","sources":["../../src/reporter/PlaywrightStepReporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAoE,MAAM,8BAA8B,CAAC;AAiC7H,qBAAa,sBAAuB,YAAW,eAAe;IAKtD,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,KAAK,CAAC;IAJlB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA4C;gBAG7C,QAAQ,EAAE,QAAQ,EAC3B,KAAK,CAAC,EAAE,KAAK;IAIzB,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,eAAe;IAMzC,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI;IAmBlC,OAAO,CAAC,UAAU;CAYrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlaywrightStepReporter.js","sourceRoot":"","sources":["../../src/reporter/PlaywrightStepReporter.ts"],"names":[],"mappings":";;;AAEA,yDAA6H;AAC7H,uDAAiF;
|
|
1
|
+
{"version":3,"file":"PlaywrightStepReporter.js","sourceRoot":"","sources":["../../src/reporter/PlaywrightStepReporter.ts"],"names":[],"mappings":";;;AAEA,yDAA6H;AAC7H,uDAAiF;AAgCjF,MAAa,sBAAsB;IAI/B,YACqB,QAAkB,EAC3B,KAAa;QADJ,aAAQ,GAAR,QAAQ,CAAU;QAC3B,UAAK,GAAL,KAAK,CAAQ;QAJR,UAAK,GAAkC,IAAI,GAAG,EAAE,CAAC;IAMlE,CAAC;IAED,UAAU,CAAC,KAAY;QACnB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QAEnB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,QAAQ,CAAC,KAAkB;QAEvB,IAAI,KAAK,YAAY,mBAAU,EAAE;YAC7B,IAAI,CAAC,KAAK,CAAC,GAAG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AAK;SACvB,CAAqB,CAAC;IAC3B,CAAC;CACJ;AA/CD,wDA+CC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FullConfig } from '@playwright/test';
|
|
2
|
-
import { Reporter, Suite, TestCase, TestResult } from '@playwright/test/reporter';
|
|
1
|
+
import type { FullConfig } from '@playwright/test';
|
|
2
|
+
import type { Reporter, Suite, TestCase, TestResult } from '@playwright/test/reporter';
|
|
3
3
|
import { Serenity, StageCrewMember, StageCrewMemberBuilder } from '@serenity-js/core';
|
|
4
4
|
import { OutputStream } from '@serenity-js/core/lib/adapter';
|
|
5
5
|
export declare class SerenityReporterForPlaywrightTestConfig {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SerenityReporterForPlaywrightTest.d.ts","sourceRoot":"","sources":["../../src/reporter/SerenityReporterForPlaywrightTest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"SerenityReporterForPlaywrightTest.d.ts","sourceRoot":"","sources":["../../src/reporter/SerenityReporterForPlaywrightTest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,kBAAkB,CAAC;AAC9D,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvF,OAAO,EAAc,QAAQ,EAAwC,eAAe,EAAE,sBAAsB,EAAa,MAAM,mBAAmB,CAAC;AACnJ,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAkC7D,qBAAa,uCAAuC;IAChD;;;OAGG;IACH,IAAI,CAAC,EAAE,KAAK,CAAC,eAAe,GAAG,sBAAsB,CAAC,CAAC;IAEvD;;;;OAIG;IACH,YAAY,CAAC,EAAE,YAAY,CAAC;CAC/B;AAED;;;GAGG;AACH,qBAAa,iCAAkC,YAAW,QAAQ;IAc1D,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAZ7B,OAAO,CAAC,WAAW,CAA+B;IAClD,OAAO,CAAC,QAAQ,CAAyC;IAEzD;;;;;;OAMG;gBAEC,MAAM,EAAE,uCAAuC,EAC9B,QAAQ,GAAE,QAAmC;IAKlE,OAAO,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI;IAI/C,WAAW,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI;IAwBjC,SAAS,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI;IA0CnD,OAAO,CAAC,wBAAwB;IAUhC,OAAO,CAAC,WAAW;IAwBnB,OAAO,CAAC,mBAAmB;IAcrB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAY5B,OAAO,CAAC,IAAI;IAMZ,OAAO,CAAC,qBAAqB;IA8B7B,OAAO,CAAC,GAAG;IAIX,aAAa,IAAI,OAAO;CAG3B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serenity-js/playwright-test",
|
|
3
|
-
"version": "3.0.0-rc.
|
|
3
|
+
"version": "3.0.0-rc.38",
|
|
4
4
|
"description": "Serenity/JS Screenplay Pattern library for Playwright",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Jan Molak",
|
|
@@ -44,16 +44,14 @@
|
|
|
44
44
|
"npm": "^6 || ^7 || ^8"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@
|
|
48
|
-
"@serenity-js/
|
|
47
|
+
"@playwright/test": "^1.29.1",
|
|
48
|
+
"@serenity-js/core": "3.0.0-rc.38",
|
|
49
|
+
"@serenity-js/playwright": "3.0.0-rc.38",
|
|
49
50
|
"deepmerge": "^4.2.2",
|
|
50
51
|
"tiny-types": "^1.19.0"
|
|
51
52
|
},
|
|
52
53
|
"devDependencies": {
|
|
53
54
|
"@integration/testing-tools": "3.0.0",
|
|
54
|
-
"@playwright/test": "1.29.0",
|
|
55
|
-
"@serenity-js/core": "3.0.0-rc.27",
|
|
56
|
-
"@serenity-js/playwright": "3.0.0-rc.27",
|
|
57
55
|
"@types/chai": "^4.3.4",
|
|
58
56
|
"@types/mocha": "^10.0.1",
|
|
59
57
|
"mocha": "^10.2.0",
|
|
@@ -61,5 +59,5 @@
|
|
|
61
59
|
"ts-node": "^10.9.1",
|
|
62
60
|
"typescript": "^4.9.4"
|
|
63
61
|
},
|
|
64
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "3472a2338ceea7267e24147635c0cc1ce4ff70fe"
|
|
65
63
|
}
|
package/src/api.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions, test as base, TestInfo, TestType } from '@playwright/test';
|
|
2
|
-
import { Actor, Cast, Duration, Serenity, serenity as serenityInstance,
|
|
2
|
+
import { Actor, Cast, Duration, Serenity, serenity as serenityInstance, StageCrewMember } from '@serenity-js/core';
|
|
3
3
|
import { SceneFinishes, SceneTagged } from '@serenity-js/core/lib/events';
|
|
4
4
|
import { BrowserTag, PlatformTag } from '@serenity-js/core/lib/model';
|
|
5
5
|
import { BrowseTheWebWithPlaywright } from '@serenity-js/playwright';
|
|
@@ -8,19 +8,166 @@ import { JSONValue } from 'tiny-types';
|
|
|
8
8
|
|
|
9
9
|
import { DomainEventBuffer, PlaywrightStepReporter, SERENITY_JS_DOMAIN_EVENTS_ATTACHMENT_CONTENT_TYPE } from './reporter';
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Serenity/JS-specific [Playwright Test fixtures](https://playwright.dev/docs/test-fixtures).
|
|
13
|
+
*
|
|
14
|
+
* ## Example test scenario
|
|
15
|
+
*
|
|
16
|
+
* ```typescript
|
|
17
|
+
* import { Ensure, equals } from '@serenity-js/assertions'
|
|
18
|
+
* import { describe, it, test } from '@serenity-js/playwright-test'
|
|
19
|
+
* import { Photographer, TakePhotosOfFailures } from '@serenity-js/web'
|
|
20
|
+
*
|
|
21
|
+
* describe(`Recording items`, () => {
|
|
22
|
+
*
|
|
23
|
+
* test.use({
|
|
24
|
+
* defaultActorName: 'Serena',
|
|
25
|
+
* crew: [
|
|
26
|
+
* Photographer.whoWill(TakePhotosOfFailures),
|
|
27
|
+
* ],
|
|
28
|
+
* })
|
|
29
|
+
*
|
|
30
|
+
* describe(`Todo List App`, () => {
|
|
31
|
+
*
|
|
32
|
+
* it(`should allow me to add a todo item`, async ({ actor }) => {
|
|
33
|
+
* await actor.attemptsTo(
|
|
34
|
+
* startWithAnEmptyList(),
|
|
35
|
+
*
|
|
36
|
+
* recordItem('Buy some milk'),
|
|
37
|
+
*
|
|
38
|
+
* Ensure.that(itemNames(), equals([
|
|
39
|
+
* 'Buy some milk',
|
|
40
|
+
* ])),
|
|
41
|
+
* )
|
|
42
|
+
* })
|
|
43
|
+
* })
|
|
44
|
+
* })
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* ## Learn more
|
|
48
|
+
* - Declaring a test scenario using {@apilink it}
|
|
49
|
+
* - Grouping test scenarios using {@apilink describe}
|
|
50
|
+
* - [Serenity/JS + Playwright Test project template](https://github.com/serenity-js/serenity-js-playwright-test-template/)
|
|
51
|
+
*/
|
|
52
|
+
export interface SerenityFixtures {
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Configures the {@apilink Cast} of {@apilink SerenityConfig.actors|actors} to be used when injecting an {@apilink SerenityFixtures.actor|actor}
|
|
56
|
+
* or invoking {@apilink SerenityFixtures.actorCalled|actorCalled} in a {@apilink it|test scenario}.
|
|
57
|
+
*
|
|
58
|
+
* #### Learn more
|
|
59
|
+
* - Declaring a test scenario using {@apilink it}
|
|
60
|
+
*/
|
|
12
61
|
actors: Cast;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Configures the {@apilink SerenityConfig.crew|stage crew}
|
|
65
|
+
*/
|
|
13
66
|
crew: StageCrewMember[];
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Configures the {@apilink SerenityConfig.cueTimeout|cueTimeout}
|
|
70
|
+
*/
|
|
14
71
|
cueTimeout: Duration;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Retrieves the root object of the Serenity/JS framework.
|
|
75
|
+
*/
|
|
15
76
|
serenity: Serenity;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Name and version of the operating system the Playwright Test runs on.
|
|
80
|
+
*/
|
|
16
81
|
platform: { name: string, version: string };
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Uses the provided {@apilink Cast} of {@apilink SerenityFixtures.actors|actors} to instantiate an {@apilink Actor} called `name`
|
|
85
|
+
* and inject it into a {@apilink it|test scenario}.
|
|
86
|
+
* Retrieves an existing actor if one has already been instantiated.
|
|
87
|
+
*
|
|
88
|
+
* #### Learn more
|
|
89
|
+
* - Declaring a test scenario using {@apilink it}
|
|
90
|
+
*
|
|
91
|
+
* @param name
|
|
92
|
+
*/
|
|
17
93
|
actorCalled: (name: string) => Actor;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Configures the name given to the default {@apilink SerenityFixtures.actor|actor} injected into the {@apilink it|test scenario}.
|
|
97
|
+
*
|
|
98
|
+
* #### Learn more
|
|
99
|
+
* - Declaring a test scenario using {@apilink it}
|
|
100
|
+
*/
|
|
18
101
|
defaultActorName: string;
|
|
102
|
+
/**
|
|
103
|
+
* Default {@apilink SerenityFixtures.actor|actor} injected into a {@apilink it|test scenario}.
|
|
104
|
+
*
|
|
105
|
+
* #### Learn more
|
|
106
|
+
* - {@apilink SerenityFixtures.actorCalled|actorCalled}
|
|
107
|
+
* - Declaring a test scenario using {@apilink it}
|
|
108
|
+
*/
|
|
19
109
|
actor: Actor;
|
|
20
110
|
}
|
|
21
111
|
|
|
22
112
|
export type SerenityTestType = TestType<PlaywrightTestArgs & PlaywrightTestOptions & SerenityFixtures, PlaywrightWorkerArgs & PlaywrightWorkerOptions>;
|
|
23
113
|
|
|
114
|
+
/**
|
|
115
|
+
* Declares a single test scenario.
|
|
116
|
+
*
|
|
117
|
+
* ## Example
|
|
118
|
+
*
|
|
119
|
+
* ```typescript
|
|
120
|
+
* import { Ensure, equals } from '@serenity-js/assertions'
|
|
121
|
+
* import { describe, it } from '@serenity-js/playwright-test'
|
|
122
|
+
*
|
|
123
|
+
* describe(`Todo List App`, () => {
|
|
124
|
+
*
|
|
125
|
+
* it(`should allow me to add a todo item`, async ({ actor }) => {
|
|
126
|
+
* await actor.attemptsTo(
|
|
127
|
+
* startWithAnEmptyList(),
|
|
128
|
+
*
|
|
129
|
+
* recordItem('Buy some milk'),
|
|
130
|
+
*
|
|
131
|
+
* Ensure.that(itemNames(), equals([
|
|
132
|
+
* 'Buy some milk',
|
|
133
|
+
* ])),
|
|
134
|
+
* )
|
|
135
|
+
* })
|
|
136
|
+
*
|
|
137
|
+
* it('supports multiple actors using separate browsers', async ({ actorCalled }) => {
|
|
138
|
+
* await actorCalled('Alice').attemptsTo(
|
|
139
|
+
* startWithAListContaining(
|
|
140
|
+
* 'Feed the cat'
|
|
141
|
+
* ),
|
|
142
|
+
* )
|
|
143
|
+
*
|
|
144
|
+
* await actorCalled('Bob').attemptsTo(
|
|
145
|
+
* startWithAListContaining(
|
|
146
|
+
* 'Walk the dog'
|
|
147
|
+
* ),
|
|
148
|
+
* )
|
|
149
|
+
*
|
|
150
|
+
* await actorCalled('Alice').attemptsTo(
|
|
151
|
+
* Ensure.that(itemNames(), equals([
|
|
152
|
+
* 'Feed the cat'
|
|
153
|
+
* ])),
|
|
154
|
+
* )
|
|
155
|
+
*
|
|
156
|
+
* await actorCalled('Bob').attemptsTo(
|
|
157
|
+
* Ensure.that(itemNames(), equals([
|
|
158
|
+
* 'Walk the dog'
|
|
159
|
+
* ])),
|
|
160
|
+
* )
|
|
161
|
+
* })
|
|
162
|
+
* })
|
|
163
|
+
* ```
|
|
164
|
+
*
|
|
165
|
+
* ## Learn more
|
|
166
|
+
* - Grouping test scenarios using {@apilink describe}
|
|
167
|
+
* - {@apilink SerenityFixtures}
|
|
168
|
+
* - [Playwright Test `test` function](https://playwright.dev/docs/api/class-test#test-call)
|
|
169
|
+
* - [Serenity/JS + Playwright Test project template](https://github.com/serenity-js/serenity-js-playwright-test-template/)
|
|
170
|
+
*/
|
|
24
171
|
export const it: SerenityTestType = base.extend<SerenityFixtures>({
|
|
25
172
|
cueTimeout: Duration.ofSeconds(5),
|
|
26
173
|
|
|
@@ -113,6 +260,55 @@ export const it: SerenityTestType = base.extend<SerenityFixtures>({
|
|
|
113
260
|
});
|
|
114
261
|
|
|
115
262
|
export const test: SerenityTestType = it;
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Declares a group of test scenarios.
|
|
266
|
+
*
|
|
267
|
+
* ## Example
|
|
268
|
+
*
|
|
269
|
+
* ```typescript
|
|
270
|
+
* import { Ensure, equals } from '@serenity-js/assertions'
|
|
271
|
+
* import { describe, it, test } from '@serenity-js/playwright-test'
|
|
272
|
+
* import { Photographer, TakePhotosOfFailures, Value } from '@serenity-js/web'
|
|
273
|
+
*
|
|
274
|
+
* describe(`Todo List App`, () => {
|
|
275
|
+
*
|
|
276
|
+
* test.use({
|
|
277
|
+
* defaultActorName: 'Serena',
|
|
278
|
+
* crew: [
|
|
279
|
+
* Photographer.whoWill(TakePhotosOfFailures),
|
|
280
|
+
* ],
|
|
281
|
+
* })
|
|
282
|
+
*
|
|
283
|
+
* it(`should allow me to add a todo item`, async ({ actor }) => {
|
|
284
|
+
* await actor.attemptsTo(
|
|
285
|
+
* startWithAnEmptyList(),
|
|
286
|
+
*
|
|
287
|
+
* recordItem('Buy some milk'),
|
|
288
|
+
*
|
|
289
|
+
* Ensure.that(itemNames(), equals([
|
|
290
|
+
* 'Buy some milk',
|
|
291
|
+
* ])),
|
|
292
|
+
* )
|
|
293
|
+
* })
|
|
294
|
+
*
|
|
295
|
+
* it('should clear text input field when an item is added', async ({ actor }) => {
|
|
296
|
+
* await actor.attemptsTo(
|
|
297
|
+
* startWithAnEmptyList(),
|
|
298
|
+
*
|
|
299
|
+
* recordItem('Buy some milk'),
|
|
300
|
+
*
|
|
301
|
+
* Ensure.that(Value.of(newTodoInput()), equals('')),
|
|
302
|
+
* )
|
|
303
|
+
* })
|
|
304
|
+
* })
|
|
305
|
+
* ```
|
|
306
|
+
*
|
|
307
|
+
* ## Learn more
|
|
308
|
+
* - Declaring a test scenario using {@apilink it}
|
|
309
|
+
* - [Playwright Test `describe` function](https://playwright.dev/docs/api/class-test#test-describe-1)
|
|
310
|
+
* - [Serenity/JS + Playwright Test project template](https://github.com/serenity-js/serenity-js-playwright-test-template/)
|
|
311
|
+
*/
|
|
116
312
|
export const describe: SerenityTestType['describe'] = it.describe;
|
|
117
313
|
export const beforeAll: SerenityTestType['beforeAll'] = it.beforeAll;
|
|
118
314
|
export const beforeEach: SerenityTestType['beforeEach'] = it.beforeEach;
|
|
@@ -9,12 +9,12 @@ interface Location {
|
|
|
9
9
|
* Path to the source file.
|
|
10
10
|
*/
|
|
11
11
|
file: string;
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
/**
|
|
14
14
|
* Line number in the source file.
|
|
15
15
|
*/
|
|
16
16
|
line: number;
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
/**
|
|
19
19
|
* Column number in the source file.
|
|
20
20
|
*/
|
|
@@ -24,6 +24,7 @@ interface Location {
|
|
|
24
24
|
// https://github.com/microsoft/playwright/blob/04f77f231981780704a3a5e2cea93e3c420809a0/packages/playwright-test/src/types.ts#L30
|
|
25
25
|
interface TestStepInternal {
|
|
26
26
|
complete(result: { error?: Error | TestError }): void;
|
|
27
|
+
|
|
27
28
|
title: string;
|
|
28
29
|
category: string;
|
|
29
30
|
canHaveChildren: boolean;
|
|
@@ -60,10 +61,9 @@ export class PlaywrightStepReporter implements StageCrewMember {
|
|
|
60
61
|
|
|
61
62
|
if (event instanceof InteractionFinished || event instanceof TaskFinished) {
|
|
62
63
|
if (event.outcome instanceof ProblemIndication) {
|
|
63
|
-
this.steps.get(event.activityId.value).complete({ error: event.outcome.error })
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
this.steps.get(event.activityId.value).complete({})
|
|
64
|
+
this.steps.get(event.activityId.value).complete({ error: event.outcome.error });
|
|
65
|
+
} else {
|
|
66
|
+
this.steps.get(event.activityId.value).complete({});
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
}
|
|
@@ -77,7 +77,7 @@ export class PlaywrightStepReporter implements StageCrewMember {
|
|
|
77
77
|
category: `serenity-js:${ type }`,
|
|
78
78
|
title: activityDetails.name.value,
|
|
79
79
|
canHaveChildren: true,
|
|
80
|
-
forceNoParent: false
|
|
80
|
+
forceNoParent: false,
|
|
81
81
|
}) as TestStepInternal;
|
|
82
82
|
}
|
|
83
83
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FullConfig, TestError } from '@playwright/test';
|
|
2
|
-
import { Reporter, Suite, TestCase, TestResult } from '@playwright/test/reporter';
|
|
1
|
+
import type { FullConfig, TestError } from '@playwright/test';
|
|
2
|
+
import type { Reporter, Suite, TestCase, TestResult } from '@playwright/test/reporter';
|
|
3
3
|
import { LogicError, Serenity, serenity as reporterSerenityInstance, StageCrewMember, StageCrewMemberBuilder, Timestamp } from '@serenity-js/core';
|
|
4
4
|
import { OutputStream } from '@serenity-js/core/lib/adapter';
|
|
5
5
|
import * as events from '@serenity-js/core/lib/events';
|