@serenity-js/playwright-test 3.41.2 → 3.42.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 +11 -0
- package/esm/api/PerformActivitiesAsPlaywrightSteps.d.ts +14 -0
- package/esm/api/PerformActivitiesAsPlaywrightSteps.d.ts.map +1 -0
- package/esm/api/PerformActivitiesAsPlaywrightSteps.js +40 -0
- package/esm/api/PerformActivitiesAsPlaywrightSteps.js.map +1 -0
- package/esm/api/PlaywrightTestConfig.d.ts +42 -0
- package/esm/api/PlaywrightTestConfig.d.ts.map +1 -0
- package/esm/api/PlaywrightTestConfig.js +2 -0
- package/esm/api/PlaywrightTestConfig.js.map +1 -0
- package/esm/api/WorkerEventStreamReader.d.ts +13 -0
- package/esm/api/WorkerEventStreamReader.d.ts.map +1 -0
- package/esm/api/WorkerEventStreamReader.js +18 -0
- package/esm/api/WorkerEventStreamReader.js.map +1 -0
- package/esm/api/WorkerEventStreamWriter.d.ts +24 -0
- package/esm/api/WorkerEventStreamWriter.d.ts.map +1 -0
- package/esm/api/WorkerEventStreamWriter.js +79 -0
- package/esm/api/WorkerEventStreamWriter.js.map +1 -0
- package/esm/api/index.d.ts +4 -0
- package/esm/api/index.d.ts.map +1 -0
- package/esm/api/index.js +4 -0
- package/esm/api/index.js.map +1 -0
- package/esm/api/serenity-fixtures.d.ts +452 -0
- package/esm/api/serenity-fixtures.d.ts.map +1 -0
- package/esm/api/serenity-fixtures.js +2 -0
- package/esm/api/serenity-fixtures.js.map +1 -0
- package/esm/api/test-api.d.ts +387 -0
- package/esm/api/test-api.d.ts.map +1 -0
- package/esm/api/test-api.js +521 -0
- package/esm/api/test-api.js.map +1 -0
- package/esm/events/EventFactory.d.ts +16 -0
- package/esm/events/EventFactory.d.ts.map +1 -0
- package/esm/events/EventFactory.js +90 -0
- package/esm/events/EventFactory.js.map +1 -0
- package/esm/events/PlaywrightSceneId.d.ts +7 -0
- package/esm/events/PlaywrightSceneId.d.ts.map +1 -0
- package/esm/events/PlaywrightSceneId.js +15 -0
- package/esm/events/PlaywrightSceneId.js.map +1 -0
- package/esm/events/index.d.ts +3 -0
- package/esm/events/index.d.ts.map +1 -0
- package/esm/events/index.js +3 -0
- package/esm/events/index.js.map +1 -0
- package/esm/index.d.ts +3 -0
- package/esm/index.d.ts.map +1 -0
- package/esm/index.js +3 -0
- package/esm/index.js.map +1 -0
- package/esm/reporter/PlaywrightErrorParser.d.ts +7 -0
- package/esm/reporter/PlaywrightErrorParser.d.ts.map +1 -0
- package/esm/reporter/PlaywrightErrorParser.js +23 -0
- package/esm/reporter/PlaywrightErrorParser.js.map +1 -0
- package/esm/reporter/PlaywrightEventBuffer.d.ts +25 -0
- package/esm/reporter/PlaywrightEventBuffer.d.ts.map +1 -0
- package/esm/reporter/PlaywrightEventBuffer.js +143 -0
- package/esm/reporter/PlaywrightEventBuffer.js.map +1 -0
- package/esm/reporter/PlaywrightStepReporter.d.ts +14 -0
- package/esm/reporter/PlaywrightStepReporter.d.ts.map +1 -0
- package/esm/reporter/PlaywrightStepReporter.js +38 -0
- package/esm/reporter/PlaywrightStepReporter.js.map +1 -0
- package/esm/reporter/PlaywrightTestSceneIdFactory.d.ts +8 -0
- package/esm/reporter/PlaywrightTestSceneIdFactory.d.ts.map +1 -0
- package/esm/reporter/PlaywrightTestSceneIdFactory.js +11 -0
- package/esm/reporter/PlaywrightTestSceneIdFactory.js.map +1 -0
- package/esm/reporter/SerenityReporterForPlaywrightTest.d.ts +58 -0
- package/esm/reporter/SerenityReporterForPlaywrightTest.d.ts.map +1 -0
- package/esm/reporter/SerenityReporterForPlaywrightTest.js +112 -0
- package/esm/reporter/SerenityReporterForPlaywrightTest.js.map +1 -0
- package/esm/reporter/index.d.ts +3 -0
- package/esm/reporter/index.d.ts.map +1 -0
- package/esm/reporter/index.js +3 -0
- package/esm/reporter/index.js.map +1 -0
- package/lib/api/PerformActivitiesAsPlaywrightSteps.d.ts +1 -1
- package/lib/api/PerformActivitiesAsPlaywrightSteps.d.ts.map +1 -1
- package/lib/api/PerformActivitiesAsPlaywrightSteps.js +2 -2
- package/lib/api/PerformActivitiesAsPlaywrightSteps.js.map +1 -1
- package/lib/api/PlaywrightTestConfig.d.ts +1 -1
- package/lib/api/PlaywrightTestConfig.d.ts.map +1 -1
- package/lib/api/WorkerEventStreamReader.d.ts +1 -1
- package/lib/api/WorkerEventStreamReader.d.ts.map +1 -1
- package/lib/api/WorkerEventStreamReader.js +1 -1
- package/lib/api/WorkerEventStreamReader.js.map +1 -1
- package/lib/api/WorkerEventStreamWriter.d.ts +2 -2
- package/lib/api/WorkerEventStreamWriter.d.ts.map +1 -1
- package/lib/api/WorkerEventStreamWriter.js +1 -1
- package/lib/api/WorkerEventStreamWriter.js.map +1 -1
- package/lib/api/index.d.ts +3 -3
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.js +3 -3
- package/lib/api/index.js.map +1 -1
- package/lib/api/test-api.d.ts +3 -3
- package/lib/api/test-api.d.ts.map +1 -1
- package/lib/api/test-api.js +12 -12
- package/lib/api/test-api.js.map +1 -1
- package/lib/events/EventFactory.d.ts +3 -3
- package/lib/events/EventFactory.d.ts.map +1 -1
- package/lib/events/EventFactory.js +6 -6
- package/lib/events/EventFactory.js.map +1 -1
- package/lib/events/PlaywrightSceneId.d.ts +1 -1
- package/lib/events/PlaywrightSceneId.d.ts.map +1 -1
- package/lib/events/PlaywrightSceneId.js +1 -1
- package/lib/events/PlaywrightSceneId.js.map +1 -1
- package/lib/events/index.d.ts +2 -2
- package/lib/events/index.d.ts.map +1 -1
- package/lib/events/index.js +2 -2
- package/lib/events/index.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -3
- package/lib/index.js.map +1 -1
- package/lib/package.json +1 -0
- package/lib/reporter/PlaywrightEventBuffer.d.ts +1 -1
- package/lib/reporter/PlaywrightEventBuffer.d.ts.map +1 -1
- package/lib/reporter/PlaywrightEventBuffer.js +12 -12
- package/lib/reporter/PlaywrightEventBuffer.js.map +1 -1
- package/lib/reporter/PlaywrightStepReporter.d.ts +1 -1
- package/lib/reporter/PlaywrightStepReporter.d.ts.map +1 -1
- package/lib/reporter/PlaywrightStepReporter.js +2 -2
- package/lib/reporter/PlaywrightStepReporter.js.map +1 -1
- package/lib/reporter/PlaywrightTestSceneIdFactory.d.ts +2 -2
- package/lib/reporter/PlaywrightTestSceneIdFactory.d.ts.map +1 -1
- package/lib/reporter/PlaywrightTestSceneIdFactory.js +1 -1
- package/lib/reporter/PlaywrightTestSceneIdFactory.js.map +1 -1
- package/lib/reporter/SerenityReporterForPlaywrightTest.d.ts +1 -1
- package/lib/reporter/SerenityReporterForPlaywrightTest.d.ts.map +1 -1
- package/lib/reporter/SerenityReporterForPlaywrightTest.js +8 -8
- package/lib/reporter/SerenityReporterForPlaywrightTest.js.map +1 -1
- package/lib/reporter/index.d.ts +2 -2
- package/lib/reporter/index.d.ts.map +1 -1
- package/lib/reporter/index.js +2 -2
- package/lib/reporter/index.js.map +1 -1
- package/package.json +57 -9
- package/src/api/PerformActivitiesAsPlaywrightSteps.ts +2 -2
- package/src/api/PlaywrightTestConfig.ts +1 -1
- package/src/api/WorkerEventStreamReader.ts +2 -2
- package/src/api/WorkerEventStreamWriter.ts +2 -2
- package/src/api/index.ts +3 -3
- package/src/api/test-api.ts +8 -8
- package/src/events/EventFactory.ts +5 -5
- package/src/events/PlaywrightSceneId.ts +1 -1
- package/src/events/index.ts +2 -2
- package/src/index.ts +2 -2
- package/src/reporter/PlaywrightEventBuffer.ts +8 -8
- package/src/reporter/PlaywrightStepReporter.ts +4 -4
- package/src/reporter/PlaywrightTestSceneIdFactory.ts +2 -2
- package/src/reporter/SerenityReporterForPlaywrightTest.ts +6 -6
- package/src/reporter/index.ts +2 -2
- package/tsconfig-cjs.build.json +18 -0
- package/tsconfig-esm.build.json +18 -0
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
import type { Expect, Fixtures, PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions, TestInfo, TestType } from '@playwright/test';
|
|
2
|
+
import type { DiffFormatter } from '@serenity-js/core';
|
|
3
|
+
import { PlaywrightTestSceneIdFactory } from '../reporter/PlaywrightTestSceneIdFactory.js';
|
|
4
|
+
import type { SerenityFixtures, SerenityWorkerFixtures } from './serenity-fixtures.js';
|
|
5
|
+
import { WorkerEventStreamWriter } from './WorkerEventStreamWriter.js';
|
|
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>;
|
|
16
|
+
/**
|
|
17
|
+
* Serenity/JS BDD-style test API created by [`useBase`](https://serenity-js.org/api/playwright-test/function/useBase/).
|
|
18
|
+
*/
|
|
19
|
+
export type TestApi<TestArgs extends object, WorkerArgs extends object> = Pick<TestType<TestArgs, WorkerArgs>, 'describe' | 'beforeAll' | 'beforeEach' | 'afterEach' | 'afterAll' | 'expect'> & {
|
|
20
|
+
/**
|
|
21
|
+
* Creates a Serenity/JS BDD-style test API around the default Playwright [base test](https://playwright.dev/docs/test-fixtures)
|
|
22
|
+
* and using custom test fixtures.
|
|
23
|
+
*
|
|
24
|
+
* ```typescript
|
|
25
|
+
* import { useFixtures } from '@serenity-js/playwright-test'
|
|
26
|
+
* import { Log } from '@serenity-js/core'
|
|
27
|
+
*
|
|
28
|
+
* const { describe, it } = useFixtures<{ message: string }>({
|
|
29
|
+
* message: 'Hello world!'
|
|
30
|
+
* })
|
|
31
|
+
*
|
|
32
|
+
* describe('Serenity/JS useFixtures', () => {
|
|
33
|
+
*
|
|
34
|
+
* it('enables injecting custom test fixtures into test scenarios', async ({ actor, message }) => {
|
|
35
|
+
* await actor.attemptsTo(
|
|
36
|
+
* Log.the(message),
|
|
37
|
+
* )
|
|
38
|
+
* })
|
|
39
|
+
* })
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* Shorthand for [`useBase`](https://serenity-js.org/api/playwright-test/function/useBase/)
|
|
43
|
+
*/
|
|
44
|
+
useFixtures: <T extends object, W extends object = object>(customFixtures: Fixtures<T, W, TestArgs, WorkerArgs>) => TestApi<TestArgs & T, WorkerArgs & W>;
|
|
45
|
+
it: TestType<TestArgs, WorkerArgs>;
|
|
46
|
+
test: TestType<TestArgs, WorkerArgs>;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Declares a single test scenario.
|
|
50
|
+
*
|
|
51
|
+
* ## Example
|
|
52
|
+
*
|
|
53
|
+
* ```typescript
|
|
54
|
+
* import { Ensure, equals } from '@serenity-js/assertions'
|
|
55
|
+
* import { describe, it } from '@serenity-js/playwright-test'
|
|
56
|
+
*
|
|
57
|
+
* describe(`Todo List App`, () => {
|
|
58
|
+
*
|
|
59
|
+
* it(`should allow me to add a todo item`, async ({ actor }) => {
|
|
60
|
+
* await actor.attemptsTo(
|
|
61
|
+
* startWithAnEmptyList(),
|
|
62
|
+
*
|
|
63
|
+
* recordItem('Buy some milk'),
|
|
64
|
+
*
|
|
65
|
+
* Ensure.that(itemNames(), equals([
|
|
66
|
+
* 'Buy some milk',
|
|
67
|
+
* ])),
|
|
68
|
+
* )
|
|
69
|
+
* })
|
|
70
|
+
*
|
|
71
|
+
* it('supports multiple actors using separate browsers', async ({ actorCalled }) => {
|
|
72
|
+
* await actorCalled('Alice').attemptsTo(
|
|
73
|
+
* startWithAListContaining(
|
|
74
|
+
* 'Feed the cat'
|
|
75
|
+
* ),
|
|
76
|
+
* )
|
|
77
|
+
*
|
|
78
|
+
* await actorCalled('Bob').attemptsTo(
|
|
79
|
+
* startWithAListContaining(
|
|
80
|
+
* 'Walk the dog'
|
|
81
|
+
* ),
|
|
82
|
+
* )
|
|
83
|
+
*
|
|
84
|
+
* await actorCalled('Alice').attemptsTo(
|
|
85
|
+
* Ensure.that(itemNames(), equals([
|
|
86
|
+
* 'Feed the cat'
|
|
87
|
+
* ])),
|
|
88
|
+
* )
|
|
89
|
+
*
|
|
90
|
+
* await actorCalled('Bob').attemptsTo(
|
|
91
|
+
* Ensure.that(itemNames(), equals([
|
|
92
|
+
* 'Walk the dog'
|
|
93
|
+
* ])),
|
|
94
|
+
* )
|
|
95
|
+
* })
|
|
96
|
+
* })
|
|
97
|
+
* ```
|
|
98
|
+
*
|
|
99
|
+
* ## Learn more
|
|
100
|
+
* - [Grouping test scenarios](https://serenity-js.org/api/playwright-test/function/describe/)
|
|
101
|
+
* - [`SerenityFixtures`](https://serenity-js.org/api/playwright-test/interface/SerenityFixtures/)
|
|
102
|
+
* - [Playwright Test `test` function](https://playwright.dev/docs/api/class-test#test-call)
|
|
103
|
+
* - [Serenity/JS + Playwright Test project template](https://github.com/serenity-js/serenity-js-playwright-test-template/)
|
|
104
|
+
*/
|
|
105
|
+
export declare const it: TestType<PlaywrightTestArgs & PlaywrightTestOptions & SerenityFixtures, PlaywrightWorkerArgs & PlaywrightWorkerOptions & SerenityWorkerFixtures>;
|
|
106
|
+
/**
|
|
107
|
+
* Declares a single test scenario. Alias for [`it`](https://serenity-js.org/api/playwright-test/function/it/).
|
|
108
|
+
*/
|
|
109
|
+
export declare const test: TestType<PlaywrightTestArgs & PlaywrightTestOptions & SerenityFixtures, PlaywrightWorkerArgs & PlaywrightWorkerOptions & SerenityWorkerFixtures>;
|
|
110
|
+
/**
|
|
111
|
+
* Declares a group of test scenarios.
|
|
112
|
+
*
|
|
113
|
+
* ## Example
|
|
114
|
+
*
|
|
115
|
+
* ```typescript
|
|
116
|
+
* import { Ensure, equals } from '@serenity-js/assertions'
|
|
117
|
+
* import { describe, it, test } from '@serenity-js/playwright-test'
|
|
118
|
+
* import { Photographer, TakePhotosOfFailures, Value } from '@serenity-js/web'
|
|
119
|
+
*
|
|
120
|
+
* describe(`Todo List App`, () => {
|
|
121
|
+
*
|
|
122
|
+
* test.use({
|
|
123
|
+
* defaultActorName: 'Serena',
|
|
124
|
+
* crew: [
|
|
125
|
+
* Photographer.whoWill(TakePhotosOfFailures),
|
|
126
|
+
* ],
|
|
127
|
+
* })
|
|
128
|
+
*
|
|
129
|
+
* it(`should allow me to add a todo item`, async ({ actor }) => {
|
|
130
|
+
* await actor.attemptsTo(
|
|
131
|
+
* startWithAnEmptyList(),
|
|
132
|
+
*
|
|
133
|
+
* recordItem('Buy some milk'),
|
|
134
|
+
*
|
|
135
|
+
* Ensure.that(itemNames(), equals([
|
|
136
|
+
* 'Buy some milk',
|
|
137
|
+
* ])),
|
|
138
|
+
* )
|
|
139
|
+
* })
|
|
140
|
+
*
|
|
141
|
+
* it('should clear text input field when an item is added', async ({ actor }) => {
|
|
142
|
+
* await actor.attemptsTo(
|
|
143
|
+
* startWithAnEmptyList(),
|
|
144
|
+
*
|
|
145
|
+
* recordItem('Buy some milk'),
|
|
146
|
+
*
|
|
147
|
+
* Ensure.that(Value.of(newTodoInput()), equals('')),
|
|
148
|
+
* )
|
|
149
|
+
* })
|
|
150
|
+
* })
|
|
151
|
+
* ```
|
|
152
|
+
*
|
|
153
|
+
* ## Learn more
|
|
154
|
+
* - Declaring a Serenity/JS [test scenario](https://serenity-js.org/api/playwright-test/function/it/)
|
|
155
|
+
* - [Playwright Test `describe` function](https://playwright.dev/docs/api/class-test#test-describe-1)
|
|
156
|
+
* - [Serenity/JS + Playwright Test project template](https://github.com/serenity-js/serenity-js-playwright-test-template/)
|
|
157
|
+
*/
|
|
158
|
+
export declare const describe: {
|
|
159
|
+
(title: string, callback: () => void): void;
|
|
160
|
+
(callback: () => void): void;
|
|
161
|
+
(title: string, details: import("@playwright/test").TestDetails, callback: () => void): void;
|
|
162
|
+
only(title: string, callback: () => void): void;
|
|
163
|
+
only(callback: () => void): void;
|
|
164
|
+
only(title: string, details: import("@playwright/test").TestDetails, callback: () => void): void;
|
|
165
|
+
skip(title: string, callback: () => void): void;
|
|
166
|
+
skip(callback: () => void): void;
|
|
167
|
+
skip(title: string, details: import("@playwright/test").TestDetails, callback: () => void): void;
|
|
168
|
+
fixme(title: string, callback: () => void): void;
|
|
169
|
+
fixme(callback: () => void): void;
|
|
170
|
+
fixme(title: string, details: import("@playwright/test").TestDetails, callback: () => void): void;
|
|
171
|
+
serial: {
|
|
172
|
+
(title: string, callback: () => void): void;
|
|
173
|
+
(callback: () => void): void;
|
|
174
|
+
(title: string, details: import("@playwright/test").TestDetails, callback: () => void): void;
|
|
175
|
+
only(title: string, callback: () => void): void;
|
|
176
|
+
only(callback: () => void): void;
|
|
177
|
+
only(title: string, details: import("@playwright/test").TestDetails, callback: () => void): void;
|
|
178
|
+
};
|
|
179
|
+
parallel: {
|
|
180
|
+
(title: string, callback: () => void): void;
|
|
181
|
+
(callback: () => void): void;
|
|
182
|
+
(title: string, details: import("@playwright/test").TestDetails, callback: () => void): void;
|
|
183
|
+
only(title: string, callback: () => void): void;
|
|
184
|
+
only(callback: () => void): void;
|
|
185
|
+
only(title: string, details: import("@playwright/test").TestDetails, callback: () => void): void;
|
|
186
|
+
};
|
|
187
|
+
configure: (options: {
|
|
188
|
+
mode?: "default" | "parallel" | "serial";
|
|
189
|
+
retries?: number;
|
|
190
|
+
timeout?: number;
|
|
191
|
+
}) => void;
|
|
192
|
+
};
|
|
193
|
+
export declare const beforeAll: {
|
|
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;
|
|
196
|
+
};
|
|
197
|
+
export declare const beforeEach: {
|
|
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;
|
|
200
|
+
};
|
|
201
|
+
export declare const afterEach: {
|
|
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;
|
|
204
|
+
};
|
|
205
|
+
export declare const afterAll: {
|
|
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;
|
|
208
|
+
};
|
|
209
|
+
export declare const expect: Expect;
|
|
210
|
+
export declare const useFixtures: <T extends object, W extends object = object>(customFixtures: Fixtures<T, W, PlaywrightTestArgs & PlaywrightTestOptions & SerenityFixtures, PlaywrightWorkerArgs & PlaywrightWorkerOptions & SerenityWorkerFixtures>) => TestApi<PlaywrightTestArgs & PlaywrightTestOptions & SerenityFixtures & T, PlaywrightWorkerArgs & PlaywrightWorkerOptions & SerenityWorkerFixtures & W>;
|
|
211
|
+
type MergedT<List> = List extends [TestType<infer T, any>, ...(infer Rest)] ? T & MergedT<Rest> : object;
|
|
212
|
+
type MergedW<List> = List extends [TestType<any, infer W>, ...(infer Rest)] ? W & MergedW<Rest> : object;
|
|
213
|
+
/**
|
|
214
|
+
* Creates a Serenity/JS BDD-style test API around the given Playwright [base test](https://playwright.dev/docs/test-fixtures).
|
|
215
|
+
*
|
|
216
|
+
* ## Using default configuration
|
|
217
|
+
*
|
|
218
|
+
* When your test scenario doesn't require [custom test fixtures](https://playwright.dev/docs/test-fixtures),
|
|
219
|
+
* and you're happy with the default [base test](https://playwright.dev/docs/api/class-test#test-call) offered by Playwright,
|
|
220
|
+
* you can import test API functions such as [`describe`](https://serenity-js.org/api/playwright-test/function/describe/) and [`it`](https://serenity-js.org/api/playwright-test/function/describe/) directly from `@serenity-js/playwright-test`.
|
|
221
|
+
*
|
|
222
|
+
* ```typescript
|
|
223
|
+
* import { describe, it, test } from '@serenity-js/playwright-test'
|
|
224
|
+
* import { Log } from '@serenity-js/core'
|
|
225
|
+
*
|
|
226
|
+
* // override default fixtures if needed
|
|
227
|
+
* test.use({
|
|
228
|
+
* defaultActorName: 'Alice'
|
|
229
|
+
* })
|
|
230
|
+
*
|
|
231
|
+
* describe('Serenity/JS default test API', () => {
|
|
232
|
+
*
|
|
233
|
+
* it('enables easy access to actors and standard Playwright fixtures', async ({ actor, browserName }) => {
|
|
234
|
+
* await actor.attemptsTo(
|
|
235
|
+
* Log.the(browserName),
|
|
236
|
+
* )
|
|
237
|
+
* })
|
|
238
|
+
* })
|
|
239
|
+
* ```
|
|
240
|
+
*
|
|
241
|
+
* In the above example, importing test API functions directly from `@serenity-js/playwright-test` is the equivalent of the following setup:
|
|
242
|
+
*
|
|
243
|
+
* ```typescript
|
|
244
|
+
* import { test as playwrightBaseTest } from '@playwright/test'
|
|
245
|
+
* import { useBase } from '@serenity-js/playwright-test'
|
|
246
|
+
*
|
|
247
|
+
* const { describe, it, test, beforeEach, afterEach } = useBase(playwrightBaseTest)
|
|
248
|
+
* ```
|
|
249
|
+
*
|
|
250
|
+
* ## Using custom fixtures
|
|
251
|
+
*
|
|
252
|
+
* When your test scenario requires [custom test fixtures](https://playwright.dev/docs/test-fixtures),
|
|
253
|
+
* but you're still happy with the default [base test](https://playwright.dev/docs/api/class-test#test-call) offered by Playwright,
|
|
254
|
+
* you can create fixture-aware test API functions such as [`describe`](https://serenity-js.org/api/playwright-test/function/describe/) and [`it`](https://serenity-js.org/api/playwright-test/function/describe/)
|
|
255
|
+
* by calling [`useFixtures`](https://serenity-js.org/api/playwright-test/function/useFixtures/).
|
|
256
|
+
*
|
|
257
|
+
* For example, you can create a test scenario using a static `message` fixture as follows:
|
|
258
|
+
*
|
|
259
|
+
* ```typescript
|
|
260
|
+
* import { useFixtures } from '@serenity-js/playwright-test'
|
|
261
|
+
* import { Log } from '@serenity-js/core'
|
|
262
|
+
*
|
|
263
|
+
* const { describe, it } = useFixtures<{ message: string }>({
|
|
264
|
+
* message: 'Hello world!'
|
|
265
|
+
* })
|
|
266
|
+
*
|
|
267
|
+
* describe('Serenity/JS useFixtures', () => {
|
|
268
|
+
*
|
|
269
|
+
* it('enables injecting custom test fixtures into test scenarios', async ({ actor, message }) => {
|
|
270
|
+
* await actor.attemptsTo(
|
|
271
|
+
* Log.the(message),
|
|
272
|
+
* )
|
|
273
|
+
* })
|
|
274
|
+
* })
|
|
275
|
+
* ```
|
|
276
|
+
*
|
|
277
|
+
* The value of your test fixtures can be either static or dynamic and based on the value of other fixtures.
|
|
278
|
+
*
|
|
279
|
+
* To create a dynamic test fixture use the [function syntax](https://playwright.dev/docs/test-fixtures):
|
|
280
|
+
*
|
|
281
|
+
* ```typescript
|
|
282
|
+
* import { Log } from '@serenity-js/core'
|
|
283
|
+
* import { useFixtures } from '@serenity-js/playwright-test'
|
|
284
|
+
*
|
|
285
|
+
* const { describe, it } = useFixtures<{ message: string }>({
|
|
286
|
+
* message: async ({ actor }, use) => {
|
|
287
|
+
* await use(`Hello, ${ actor.name }`);
|
|
288
|
+
* }
|
|
289
|
+
* })
|
|
290
|
+
*
|
|
291
|
+
* describe('Serenity/JS useFixtures', () => {
|
|
292
|
+
*
|
|
293
|
+
* it('enables injecting custom test fixtures into test scenarios', async ({ actor, message }) => {
|
|
294
|
+
* await actor.attemptsTo(
|
|
295
|
+
* Log.the(message),
|
|
296
|
+
* )
|
|
297
|
+
* })
|
|
298
|
+
* })
|
|
299
|
+
* ```
|
|
300
|
+
*
|
|
301
|
+
* In the above example, creating test API functions via `useFixtures` is the equivalent of the following setup:
|
|
302
|
+
*
|
|
303
|
+
* ```typescript
|
|
304
|
+
* import { test as playwrightBaseTest } from '@playwright/test'
|
|
305
|
+
* import { useBase } from '@serenity-js/playwright-test'
|
|
306
|
+
*
|
|
307
|
+
* const { describe, it, test, beforeEach, afterEach } = useBase(playwrightBaseTest)
|
|
308
|
+
* .useFixtures<{ message: string }>({
|
|
309
|
+
* message: async ({ actor }, use) => {
|
|
310
|
+
* await use(`Hello, ${ actor.name }`);
|
|
311
|
+
* }
|
|
312
|
+
* })
|
|
313
|
+
* ```
|
|
314
|
+
*
|
|
315
|
+
* ## Using custom base test
|
|
316
|
+
*
|
|
317
|
+
* In cases where you need to use a non-default base test, for example when doing [UI component testing](https://playwright.dev/docs/test-components),
|
|
318
|
+
* you can create Serenity/JS test API functions around your preferred base test.
|
|
319
|
+
*
|
|
320
|
+
* ```tsx
|
|
321
|
+
* import { test as componentTest } from '@playwright/experimental-ct-react'
|
|
322
|
+
* import { Ensure, contain } from '@serenity-js/assertions'
|
|
323
|
+
* import { useBase } from '@serenity-js/playwright-test'
|
|
324
|
+
* import { Enter, PageElement, CssClasses } from '@serenity-js/web'
|
|
325
|
+
*
|
|
326
|
+
* import EmailInput from './EmailInput';
|
|
327
|
+
*
|
|
328
|
+
* const { it, describe } = useBase(componentTest).useFixtures<{ emailAddress: string }>({
|
|
329
|
+
* emailAddress: ({ actor }, use) => {
|
|
330
|
+
* use(`${ actor.name }@example.org`)
|
|
331
|
+
* }
|
|
332
|
+
* })
|
|
333
|
+
*
|
|
334
|
+
* describe('EmailInput', () => {
|
|
335
|
+
*
|
|
336
|
+
* it('allows valid email addresses', async ({ actor, mount, emailAddress }) => {
|
|
337
|
+
* const nativeComponent = await mount(<EmailInput/>);
|
|
338
|
+
*
|
|
339
|
+
* const component = PageElement.from(nativeComponent);
|
|
340
|
+
*
|
|
341
|
+
* await actor.attemptsTo(
|
|
342
|
+
* Enter.theValue(emailAddress).into(component),
|
|
343
|
+
* Ensure.that(CssClasses.of(component), contain('valid')),
|
|
344
|
+
* )
|
|
345
|
+
* })
|
|
346
|
+
* })
|
|
347
|
+
* ```
|
|
348
|
+
*
|
|
349
|
+
* ## Merging multiple base tests
|
|
350
|
+
*
|
|
351
|
+
* To merge fixtures from multiple files or modules, pass them to `useBase`.
|
|
352
|
+
*
|
|
353
|
+
* ```tsx
|
|
354
|
+
* import { test as componentTest } from '@playwright/experimental-ct-react'
|
|
355
|
+
* import { test as a11yTest } from 'my-a11y-test-utils';
|
|
356
|
+
* import { Ensure, contain } from '@serenity-js/assertions'
|
|
357
|
+
* import { useBase } from '@serenity-js/playwright-test'
|
|
358
|
+
* import { Enter, PageElement, CssClasses } from '@serenity-js/web'
|
|
359
|
+
*
|
|
360
|
+
* import EmailInput from './EmailInput';
|
|
361
|
+
*
|
|
362
|
+
* const { it, describe } = useBase(componentTest, a11yTest).useFixtures<{ emailAddress: string }>({
|
|
363
|
+
* emailAddress: ({ actor }, use) => {
|
|
364
|
+
* use(`${ actor.name }@example.org`)
|
|
365
|
+
* }
|
|
366
|
+
* })
|
|
367
|
+
*
|
|
368
|
+
* describe('EmailInput', () => {
|
|
369
|
+
*
|
|
370
|
+
* it('allows valid email addresses', async ({ actor, mount, emailAddress }) => {
|
|
371
|
+
* const nativeComponent = await mount(<EmailInput/>);
|
|
372
|
+
*
|
|
373
|
+
* const component = PageElement.from(nativeComponent);
|
|
374
|
+
*
|
|
375
|
+
* await actor.attemptsTo(
|
|
376
|
+
* Enter.theValue(emailAddress).into(component),
|
|
377
|
+
* Ensure.that(CssClasses.of(component), contain('valid')),
|
|
378
|
+
* )
|
|
379
|
+
* })
|
|
380
|
+
* })
|
|
381
|
+
* ```
|
|
382
|
+
*
|
|
383
|
+
* @param baseTests
|
|
384
|
+
*/
|
|
385
|
+
export declare function useBase<List extends any[]>(...baseTests: List): TestApi<MergedT<List> & SerenityFixtures, MergedW<List> & SerenityWorkerFixtures>;
|
|
386
|
+
export {};
|
|
387
|
+
//# sourceMappingURL=test-api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-api.d.ts","sourceRoot":"","sources":["../../src/api/test-api.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACR,MAAM,EACN,QAAQ,EACR,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,uBAAuB,EACvB,QAAQ,EACR,QAAQ,EAEX,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAWvD,OAAO,EAAE,4BAA4B,EAAE,MAAM,6CAA6C,CAAC;AAE3F,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AACvF,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAEvE,UAAU,wBAAwB;IAC9B,yBAAyB,EAAE,IAAI,CAAC;CACnC;AAED,UAAU,8BAA8B;IACpC,uBAAuB,EAAE,IAAI,CAAC;IAC9B,sBAAsB,EAAE,4BAA4B,CAAC;IACrD,qBAAqB,EAAE,aAAa,CAAC;IACrC,yBAAyB,EAAE,uBAAu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