@serenity-js/playwright-test 3.5.0 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/README.md +68 -3
- package/lib/api/DescribeFunction.d.ts +235 -0
- package/lib/api/DescribeFunction.d.ts.map +1 -0
- package/lib/api/DescribeFunction.js +3 -0
- package/lib/api/DescribeFunction.js.map +1 -0
- package/lib/api/SerenityOptions.d.ts +1 -1
- package/lib/api/SuiteFunction.d.ts +51 -0
- package/lib/api/SuiteFunction.d.ts.map +1 -0
- package/lib/api/SuiteFunction.js +3 -0
- package/lib/api/SuiteFunction.js.map +1 -0
- package/lib/api/index.d.ts +2 -1
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.js +2 -1
- package/lib/api/index.js.map +1 -1
- package/lib/api/test-api.d.ts +245 -70
- package/lib/api/test-api.d.ts.map +1 -1
- package/lib/api/test-api.js +268 -105
- package/lib/api/test-api.js.map +1 -1
- package/lib/reporter/PlaywrightStepReporter.d.ts.map +1 -1
- package/lib/reporter/PlaywrightStepReporter.js.map +1 -1
- package/package.json +6 -6
- package/src/api/DescribeFunction.ts +233 -0
- package/src/api/SerenityOptions.ts +1 -1
- package/src/api/SuiteFunction.ts +52 -0
- package/src/api/index.ts +2 -1
- package/src/api/test-api.ts +338 -124
- package/src/reporter/PlaywrightStepReporter.ts +2 -3
- package/lib/api/SerenityTestType.d.ts +0 -5
- package/lib/api/SerenityTestType.d.ts.map +0 -1
- package/lib/api/SerenityTestType.js +0 -4
- package/lib/api/SerenityTestType.js.map +0 -1
- package/src/api/SerenityTestType.ts +0 -12
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import type { SuiteFunction } from './SuiteFunction';
|
|
2
|
+
|
|
3
|
+
// todo: temporary workaround to cater for Playwright Test not exporting all its public APIs
|
|
4
|
+
// remove and use Playwright SuiteFunction when https://github.com/microsoft/playwright/pull/24146 is merged in
|
|
5
|
+
export type DescribeFunction = SuiteFunction & {
|
|
6
|
+
/**
|
|
7
|
+
* Declares a focused group of tests. If there are some focused tests or suites, all of them will be run but nothing
|
|
8
|
+
* else.
|
|
9
|
+
*
|
|
10
|
+
* **Usage**
|
|
11
|
+
*
|
|
12
|
+
* ```js
|
|
13
|
+
* test.describe.only('focused group', () => {
|
|
14
|
+
* test('in the focused group', async ({ page }) => {
|
|
15
|
+
* // This test will run
|
|
16
|
+
* });
|
|
17
|
+
* });
|
|
18
|
+
* test('not in the focused group', async ({ page }) => {
|
|
19
|
+
* // This test will not run
|
|
20
|
+
* });
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @param title Group title.
|
|
24
|
+
* @param callback A callback that is run immediately when calling
|
|
25
|
+
* [test.describe.only(title, callback)](https://playwright.dev/docs/api/class-test#test-describe-only). Any tests
|
|
26
|
+
* added in this callback will belong to the group.
|
|
27
|
+
*/
|
|
28
|
+
only: SuiteFunction;
|
|
29
|
+
/**
|
|
30
|
+
* Declares a skipped test group, similarly to
|
|
31
|
+
* [test.describe(title, callback)](https://playwright.dev/docs/api/class-test#test-describe-1). Tests in the skipped
|
|
32
|
+
* group are never run.
|
|
33
|
+
*
|
|
34
|
+
* **Usage**
|
|
35
|
+
*
|
|
36
|
+
* ```js
|
|
37
|
+
* test.describe.skip('skipped group', () => {
|
|
38
|
+
* test('example', async ({ page }) => {
|
|
39
|
+
* // This test will not run
|
|
40
|
+
* });
|
|
41
|
+
* });
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @param title Group title.
|
|
45
|
+
* @param callback A callback that is run immediately when calling
|
|
46
|
+
* [test.describe.skip(title, callback)](https://playwright.dev/docs/api/class-test#test-describe-skip). Any tests
|
|
47
|
+
* added in this callback will belong to the group, and will not be run.
|
|
48
|
+
*/
|
|
49
|
+
skip: SuiteFunction;
|
|
50
|
+
/**
|
|
51
|
+
* Declares a test group similarly to
|
|
52
|
+
* [test.describe(title, callback)](https://playwright.dev/docs/api/class-test#test-describe-1). Tests in this group
|
|
53
|
+
* are marked as "fixme" and will not be executed.
|
|
54
|
+
*
|
|
55
|
+
* **Usage**
|
|
56
|
+
*
|
|
57
|
+
* ```js
|
|
58
|
+
* test.describe.fixme('broken tests', () => {
|
|
59
|
+
* test('example', async ({ page }) => {
|
|
60
|
+
* // This test will not run
|
|
61
|
+
* });
|
|
62
|
+
* });
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* @param title Group title.
|
|
66
|
+
* @param callback A callback that is run immediately when calling
|
|
67
|
+
* [test.describe.fixme(title, callback)](https://playwright.dev/docs/api/class-test#test-describe-fixme). Any tests
|
|
68
|
+
* added in this callback will belong to the group, and will not be run.
|
|
69
|
+
*/
|
|
70
|
+
fixme: SuiteFunction;
|
|
71
|
+
/**
|
|
72
|
+
* **NOTE** See [test.describe.configure([options])](https://playwright.dev/docs/api/class-test#test-describe-configure) for
|
|
73
|
+
* the preferred way of configuring the execution mode.
|
|
74
|
+
*
|
|
75
|
+
* Declares a group of tests that should always be run serially. If one of the tests fails, all subsequent tests are
|
|
76
|
+
* skipped. All tests in a group are retried together.
|
|
77
|
+
*
|
|
78
|
+
* **NOTE** Using serial is not recommended. It is usually better to make your tests isolated, so they can be run
|
|
79
|
+
* independently.
|
|
80
|
+
*
|
|
81
|
+
* **Usage**
|
|
82
|
+
*
|
|
83
|
+
* ```js
|
|
84
|
+
* test.describe.serial('group', () => {
|
|
85
|
+
* test('runs first', async ({ page }) => {});
|
|
86
|
+
* test('runs second', async ({ page }) => {});
|
|
87
|
+
* });
|
|
88
|
+
* ```
|
|
89
|
+
*
|
|
90
|
+
* @param title Group title.
|
|
91
|
+
* @param callback A callback that is run immediately when calling
|
|
92
|
+
* [test.describe.serial(title, callback)](https://playwright.dev/docs/api/class-test#test-describe-serial). Any tests
|
|
93
|
+
* added in this callback will belong to the group.
|
|
94
|
+
*/
|
|
95
|
+
serial: SuiteFunction & {
|
|
96
|
+
/**
|
|
97
|
+
* **NOTE** See [test.describe.configure([options])](https://playwright.dev/docs/api/class-test#test-describe-configure) for
|
|
98
|
+
* the preferred way of configuring the execution mode.
|
|
99
|
+
*
|
|
100
|
+
* Declares a focused group of tests that should always be run serially. If one of the tests fails, all subsequent
|
|
101
|
+
* tests are skipped. All tests in a group are retried together. If there are some focused tests or suites, all of
|
|
102
|
+
* them will be run but nothing else.
|
|
103
|
+
*
|
|
104
|
+
* **NOTE** Using serial is not recommended. It is usually better to make your tests isolated, so they can be run
|
|
105
|
+
* independently.
|
|
106
|
+
*
|
|
107
|
+
* **Usage**
|
|
108
|
+
*
|
|
109
|
+
* ```js
|
|
110
|
+
* test.describe.serial.only('group', () => {
|
|
111
|
+
* test('runs first', async ({ page }) => {
|
|
112
|
+
* });
|
|
113
|
+
* test('runs second', async ({ page }) => {
|
|
114
|
+
* });
|
|
115
|
+
* });
|
|
116
|
+
* ```
|
|
117
|
+
*
|
|
118
|
+
* @param title Group title.
|
|
119
|
+
* @param callback A callback that is run immediately when calling
|
|
120
|
+
* [test.describe.serial.only(title, callback)](https://playwright.dev/docs/api/class-test#test-describe-serial-only).
|
|
121
|
+
* Any tests added in this callback will belong to the group.
|
|
122
|
+
*/
|
|
123
|
+
only: SuiteFunction;
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* **NOTE** See [test.describe.configure([options])](https://playwright.dev/docs/api/class-test#test-describe-configure) for
|
|
127
|
+
* the preferred way of configuring the execution mode.
|
|
128
|
+
*
|
|
129
|
+
* Declares a group of tests that could be run in parallel. By default, tests in a single test file run one after
|
|
130
|
+
* another, but using
|
|
131
|
+
* [test.describe.parallel(title, callback)](https://playwright.dev/docs/api/class-test#test-describe-parallel) allows
|
|
132
|
+
* them to run in parallel.
|
|
133
|
+
*
|
|
134
|
+
* **Usage**
|
|
135
|
+
*
|
|
136
|
+
* ```js
|
|
137
|
+
* test.describe.parallel('group', () => {
|
|
138
|
+
* test('runs in parallel 1', async ({ page }) => {});
|
|
139
|
+
* test('runs in parallel 2', async ({ page }) => {});
|
|
140
|
+
* });
|
|
141
|
+
* ```
|
|
142
|
+
*
|
|
143
|
+
* Note that parallel tests are executed in separate processes and cannot share any state or global variables. Each of
|
|
144
|
+
* the parallel tests executes all relevant hooks.
|
|
145
|
+
* @param title Group title.
|
|
146
|
+
* @param callback A callback that is run immediately when calling
|
|
147
|
+
* [test.describe.parallel(title, callback)](https://playwright.dev/docs/api/class-test#test-describe-parallel). Any
|
|
148
|
+
* tests added in this callback will belong to the group.
|
|
149
|
+
*/
|
|
150
|
+
parallel: SuiteFunction & {
|
|
151
|
+
/**
|
|
152
|
+
* **NOTE** See [test.describe.configure([options])](https://playwright.dev/docs/api/class-test#test-describe-configure) for
|
|
153
|
+
* the preferred way of configuring the execution mode.
|
|
154
|
+
*
|
|
155
|
+
* Declares a focused group of tests that could be run in parallel. This is similar to
|
|
156
|
+
* [test.describe.parallel(title, callback)](https://playwright.dev/docs/api/class-test#test-describe-parallel), but
|
|
157
|
+
* focuses the group. If there are some focused tests or suites, all of them will be run but nothing else.
|
|
158
|
+
*
|
|
159
|
+
* **Usage**
|
|
160
|
+
*
|
|
161
|
+
* ```js
|
|
162
|
+
* test.describe.parallel.only('group', () => {
|
|
163
|
+
* test('runs in parallel 1', async ({ page }) => {});
|
|
164
|
+
* test('runs in parallel 2', async ({ page }) => {});
|
|
165
|
+
* });
|
|
166
|
+
* ```
|
|
167
|
+
*
|
|
168
|
+
* @param title Group title.
|
|
169
|
+
* @param callback A callback that is run immediately when calling
|
|
170
|
+
* [test.describe.parallel.only(title, callback)](https://playwright.dev/docs/api/class-test#test-describe-parallel-only).
|
|
171
|
+
* Any tests added in this callback will belong to the group.
|
|
172
|
+
*/
|
|
173
|
+
only: SuiteFunction;
|
|
174
|
+
};
|
|
175
|
+
/**
|
|
176
|
+
* Configures the enclosing scope. Can be executed either on the top level or inside a describe. Configuration applies
|
|
177
|
+
* to the entire scope, regardless of whether it run before or after the test declaration.
|
|
178
|
+
*
|
|
179
|
+
* Learn more about the execution modes [here](https://playwright.dev/docs/test-parallel).
|
|
180
|
+
*
|
|
181
|
+
* **Usage**
|
|
182
|
+
* - Running tests in parallel.
|
|
183
|
+
*
|
|
184
|
+
* ```js
|
|
185
|
+
* // Run all the tests in the file concurrently using parallel workers.
|
|
186
|
+
* test.describe.configure({ mode: 'parallel' });
|
|
187
|
+
* test('runs in parallel 1', async ({ page }) => {});
|
|
188
|
+
* test('runs in parallel 2', async ({ page }) => {});
|
|
189
|
+
* ```
|
|
190
|
+
*
|
|
191
|
+
* - Running tests serially, retrying from the start.
|
|
192
|
+
*
|
|
193
|
+
* **NOTE** Running serially is not recommended. It is usually better to make your tests isolated, so they can be
|
|
194
|
+
* run independently.
|
|
195
|
+
*
|
|
196
|
+
* ```js
|
|
197
|
+
* // Annotate tests as inter-dependent.
|
|
198
|
+
* test.describe.configure({ mode: 'serial' });
|
|
199
|
+
* test('runs first', async ({ page }) => {});
|
|
200
|
+
* test('runs second', async ({ page }) => {});
|
|
201
|
+
* ```
|
|
202
|
+
*
|
|
203
|
+
* - Configuring retries and timeout for each test.
|
|
204
|
+
*
|
|
205
|
+
* ```js
|
|
206
|
+
* // Each test in the file will be retried twice and have a timeout of 20 seconds.
|
|
207
|
+
* test.describe.configure({ retries: 2, timeout: 20_000 });
|
|
208
|
+
* test('runs first', async ({ page }) => {});
|
|
209
|
+
* test('runs second', async ({ page }) => {});
|
|
210
|
+
* ```
|
|
211
|
+
*
|
|
212
|
+
* - Run multiple describes in parallel, but tests inside each describe in order.
|
|
213
|
+
*
|
|
214
|
+
* ```js
|
|
215
|
+
* test.describe.configure({ mode: 'parallel' });
|
|
216
|
+
*
|
|
217
|
+
* test.describe('A, runs in parallel with B', () => {
|
|
218
|
+
* test.describe.configure({ mode: 'default' });
|
|
219
|
+
* test('in order A1', async ({ page }) => {});
|
|
220
|
+
* test('in order A2', async ({ page }) => {});
|
|
221
|
+
* });
|
|
222
|
+
*
|
|
223
|
+
* test.describe('B, runs in parallel with A', () => {
|
|
224
|
+
* test.describe.configure({ mode: 'default' });
|
|
225
|
+
* test('in order B1', async ({ page }) => {});
|
|
226
|
+
* test('in order B2', async ({ page }) => {});
|
|
227
|
+
* });
|
|
228
|
+
* ```
|
|
229
|
+
*
|
|
230
|
+
* @param options
|
|
231
|
+
*/
|
|
232
|
+
configure: (options: { mode?: 'default' | 'parallel' | 'serial', retries?: number, timeout?: number }) => void;
|
|
233
|
+
}
|
|
@@ -44,7 +44,7 @@ import type { PlaywrightOptions } from '@serenity-js/playwright';
|
|
|
44
44
|
* ],
|
|
45
45
|
*
|
|
46
46
|
* // Register a custom cast of Serenity/JS actors
|
|
47
|
-
* // if you don't want to use the default
|
|
47
|
+
* // if you don't want to use the default ones
|
|
48
48
|
* actors: ({ browser, contextOptions, apiUrl }, use) => {
|
|
49
49
|
* const cast = Cast.where(actor =>
|
|
50
50
|
* actor.whoCan(
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// todo: temporary workaround to cater for Playwright Test not exporting all its public APIs
|
|
2
|
+
// remove and use Playwright SuiteFunction when https://github.com/microsoft/playwright/pull/24146 is merged in
|
|
3
|
+
export interface SuiteFunction {
|
|
4
|
+
/**
|
|
5
|
+
* Declares a group of tests.
|
|
6
|
+
*
|
|
7
|
+
* **Usage**
|
|
8
|
+
*
|
|
9
|
+
* ```js
|
|
10
|
+
* test.describe('two tests', () => {
|
|
11
|
+
* test('one', async ({ page }) => {
|
|
12
|
+
* // ...
|
|
13
|
+
* });
|
|
14
|
+
*
|
|
15
|
+
* test('two', async ({ page }) => {
|
|
16
|
+
* // ...
|
|
17
|
+
* });
|
|
18
|
+
* });
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @param title Group title.
|
|
22
|
+
* @param callback A callback that is run immediately when calling
|
|
23
|
+
* [test.describe(title, callback)](https://playwright.dev/docs/api/class-test#test-describe-1). Any tests added in
|
|
24
|
+
* this callback will belong to the group.
|
|
25
|
+
*/
|
|
26
|
+
(title: string, callback: () => void): void;
|
|
27
|
+
/**
|
|
28
|
+
* Declares an anonymous group of tests. This is convenient to give a group of tests a common option with
|
|
29
|
+
* [test.use(options)](https://playwright.dev/docs/api/class-test#test-use).
|
|
30
|
+
*
|
|
31
|
+
* **Usage**
|
|
32
|
+
*
|
|
33
|
+
* ```js
|
|
34
|
+
* test.describe(() => {
|
|
35
|
+
* test.use({ colorScheme: 'dark' });
|
|
36
|
+
*
|
|
37
|
+
* test('one', async ({ page }) => {
|
|
38
|
+
* // ...
|
|
39
|
+
* });
|
|
40
|
+
*
|
|
41
|
+
* test('two', async ({ page }) => {
|
|
42
|
+
* // ...
|
|
43
|
+
* });
|
|
44
|
+
* });
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @param callback A callback that is run immediately when calling
|
|
48
|
+
* [test.describe(callback)](https://playwright.dev/docs/api/class-test#test-describe-2). Any tests added in this
|
|
49
|
+
* callback will belong to the group.
|
|
50
|
+
*/
|
|
51
|
+
(callback: () => void): void;
|
|
52
|
+
}
|
package/src/api/index.ts
CHANGED