@serenity-js/playwright-test 3.36.2 → 3.37.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 +13 -0
- package/README.md +141 -158
- package/lib/api/serenity-fixtures.d.ts +102 -21
- package/lib/api/serenity-fixtures.d.ts.map +1 -1
- package/lib/api/test-api.d.ts +41 -5
- package/lib/api/test-api.d.ts.map +1 -1
- package/lib/api/test-api.js +62 -14
- package/lib/api/test-api.js.map +1 -1
- package/package.json +7 -6
- package/src/api/serenity-fixtures.ts +105 -20
- package/src/api/test-api.ts +81 -29
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serenity-fixtures.d.ts","sourceRoot":"","sources":["../../src/api/serenity-fixtures.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,IAAI,EACJ,gBAAgB,EAChB,QAAQ,EACR,QAAQ,EACR,eAAe,EACf,sBAAsB,EACzB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"serenity-fixtures.d.ts","sourceRoot":"","sources":["../../src/api/serenity-fixtures.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,OAAO,EACP,KAAK,EACL,IAAI,EACJ,gBAAgB,EAChB,QAAQ,EACR,QAAQ,EACR,eAAe,EACf,sBAAsB,EACzB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoGG;AACH,MAAM,WAAW,gBAAgB;IAE7B;;;;;;;OAOG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ixtures: Fixtures<SerenityFixtures & SerenityInternalFixtu
|
|
|
16
16
|
/**
|
|
17
17
|
* Serenity/JS BDD-style test API created by [`useBase`](https://serenity-js.org/api/playwright-test/function/useBase/).
|
|
18
18
|
*/
|
|
19
|
-
export type TestApi<TestArgs extends
|
|
19
|
+
export type TestApi<TestArgs extends object, WorkerArgs extends object> = Pick<TestType<TestArgs, WorkerArgs>, 'describe' | 'beforeAll' | 'beforeEach' | 'afterEach' | 'afterAll' | 'expect'> & {
|
|
20
20
|
/**
|
|
21
21
|
* Creates a Serenity/JS BDD-style test API around the default Playwright [base test](https://playwright.dev/docs/test-fixtures)
|
|
22
22
|
* and using custom test fixtures.
|
|
@@ -41,7 +41,7 @@ export type TestApi<TestArgs extends Record<string, any>, WorkerArgs extends Rec
|
|
|
41
41
|
*
|
|
42
42
|
* Shorthand for [`useBase`](https://serenity-js.org/api/playwright-test/function/useBase/)
|
|
43
43
|
*/
|
|
44
|
-
useFixtures: <T extends
|
|
44
|
+
useFixtures: <T extends object, W extends object = object>(customFixtures: Fixtures<T, W, TestArgs, WorkerArgs>) => TestApi<TestArgs & T, WorkerArgs & W>;
|
|
45
45
|
it: TestType<TestArgs, WorkerArgs>;
|
|
46
46
|
test: TestType<TestArgs, WorkerArgs>;
|
|
47
47
|
};
|
|
@@ -207,7 +207,9 @@ export declare const afterAll: {
|
|
|
207
207
|
(title: string, inner: (args: PlaywrightTestArgs & PlaywrightTestOptions & SerenityFixtures & PlaywrightWorkerArgs & PlaywrightWorkerOptions & SerenityWorkerFixtures, testInfo: TestInfo) => Promise<any> | any): void;
|
|
208
208
|
};
|
|
209
209
|
export declare const expect: Expect;
|
|
210
|
-
export declare const useFixtures: <T extends
|
|
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;
|
|
211
213
|
/**
|
|
212
214
|
* Creates a Serenity/JS BDD-style test API around the given Playwright [base test](https://playwright.dev/docs/test-fixtures).
|
|
213
215
|
*
|
|
@@ -344,8 +346,42 @@ export declare const useFixtures: <T extends Record<string, any>, W extends Reco
|
|
|
344
346
|
* })
|
|
345
347
|
* ```
|
|
346
348
|
*
|
|
347
|
-
*
|
|
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
|
|
348
384
|
*/
|
|
349
|
-
export declare function useBase<
|
|
385
|
+
export declare function useBase<List extends any[]>(...baseTests: List): TestApi<MergedT<List> & SerenityFixtures, MergedW<List> & SerenityWorkerFixtures>;
|
|
350
386
|
export {};
|
|
351
387
|
//# sourceMappingURL=test-api.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-api.d.ts","sourceRoot":"","sources":["../../src/api/test-api.ts"],"names":[],"mappings":"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,0CAA0C,CAAC;AAExF,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AACpF,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,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,uBAAuB,CAAC;CACtD;AAED,eAAO,MAAM,QAAQ,EAAE,QAAQ,CAAC,gBAAgB,GAAG,wBAAwB,EAAE,sBAAsB,GAAG,8BAA8B,EAAE,kBAAkB,GAAG,qBAAqB,EAAE,oB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C,EAAE,GAAG,CAAC,MAAM,IAAI,CAAC,CAAE,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAE3G;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2KG;AACH,wBAAgB,OAAO,CAAC,IAAI,SAAS,GAAG,EAAE,EAAE,GAAG,SAAS,EAAE,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,gBAAgB,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,sBAAsB,CAAC,CAGjJ"}
|
package/lib/api/test-api.js
CHANGED
|
@@ -42,16 +42,24 @@ exports.fixtures = {
|
|
|
42
42
|
[web_1.Photographer.whoWill(web_1.TakePhotosOfFailures)],
|
|
43
43
|
{ option: true },
|
|
44
44
|
],
|
|
45
|
+
axios: async ({ baseURL, extraHTTPHeaders, proxy }, use) => {
|
|
46
|
+
await use({
|
|
47
|
+
baseURL: baseURL,
|
|
48
|
+
headers: extraHTTPHeaders,
|
|
49
|
+
proxy: proxy && proxy?.server
|
|
50
|
+
? asProxyConfig(proxy)
|
|
51
|
+
: undefined,
|
|
52
|
+
});
|
|
53
|
+
},
|
|
45
54
|
actors: [
|
|
46
55
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
47
|
-
async ({
|
|
48
|
-
await use(core_1.Cast.where(actor =>
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}))));
|
|
56
|
+
async ({ axios, extraAbilities, extraContextOptions, page }, use) => {
|
|
57
|
+
await use(core_1.Cast.where(actor => {
|
|
58
|
+
const abilities = Array.isArray(extraAbilities)
|
|
59
|
+
? extraAbilities
|
|
60
|
+
: extraAbilities(actor.name);
|
|
61
|
+
return actor.whoCan(playwright_1.BrowseTheWebWithPlaywright.usingPage(page, extraContextOptions), core_1.TakeNotes.usingAnEmptyNotepad(), rest_1.CallAnApi.using(axios), ...abilities);
|
|
62
|
+
}));
|
|
55
63
|
},
|
|
56
64
|
{ option: true },
|
|
57
65
|
],
|
|
@@ -145,6 +153,10 @@ exports.fixtures = {
|
|
|
145
153
|
},
|
|
146
154
|
{ auto: true, box: true, }
|
|
147
155
|
],
|
|
156
|
+
extraAbilities: [
|
|
157
|
+
[],
|
|
158
|
+
{ option: true },
|
|
159
|
+
],
|
|
148
160
|
actorCalled: [
|
|
149
161
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
150
162
|
async ({ serenity }, use) => {
|
|
@@ -429,10 +441,45 @@ exports.useFixtures = api.useFixtures;
|
|
|
429
441
|
* })
|
|
430
442
|
* ```
|
|
431
443
|
*
|
|
432
|
-
*
|
|
444
|
+
* ## Merging multiple base tests
|
|
445
|
+
*
|
|
446
|
+
* To merge fixtures from multiple files or modules, pass them to `useBase`.
|
|
447
|
+
*
|
|
448
|
+
* ```tsx
|
|
449
|
+
* import { test as componentTest } from '@playwright/experimental-ct-react'
|
|
450
|
+
* import { test as a11yTest } from 'my-a11y-test-utils';
|
|
451
|
+
* import { Ensure, contain } from '@serenity-js/assertions'
|
|
452
|
+
* import { useBase } from '@serenity-js/playwright-test'
|
|
453
|
+
* import { Enter, PageElement, CssClasses } from '@serenity-js/web'
|
|
454
|
+
*
|
|
455
|
+
* import EmailInput from './EmailInput';
|
|
456
|
+
*
|
|
457
|
+
* const { it, describe } = useBase(componentTest, a11yTest).useFixtures<{ emailAddress: string }>({
|
|
458
|
+
* emailAddress: ({ actor }, use) => {
|
|
459
|
+
* use(`${ actor.name }@example.org`)
|
|
460
|
+
* }
|
|
461
|
+
* })
|
|
462
|
+
*
|
|
463
|
+
* describe('EmailInput', () => {
|
|
464
|
+
*
|
|
465
|
+
* it('allows valid email addresses', async ({ actor, mount, emailAddress }) => {
|
|
466
|
+
* const nativeComponent = await mount(<EmailInput/>);
|
|
467
|
+
*
|
|
468
|
+
* const component = PageElement.from(nativeComponent);
|
|
469
|
+
*
|
|
470
|
+
* await actor.attemptsTo(
|
|
471
|
+
* Enter.theValue(emailAddress).into(component),
|
|
472
|
+
* Ensure.that(CssClasses.of(component), contain('valid')),
|
|
473
|
+
* )
|
|
474
|
+
* })
|
|
475
|
+
* })
|
|
476
|
+
* ```
|
|
477
|
+
*
|
|
478
|
+
* @param baseTests
|
|
433
479
|
*/
|
|
434
|
-
function useBase(
|
|
435
|
-
return createTestApi(
|
|
480
|
+
function useBase(...baseTests) {
|
|
481
|
+
return createTestApi((0, test_1.mergeTests)(...baseTests))
|
|
482
|
+
.useFixtures(exports.fixtures);
|
|
436
483
|
}
|
|
437
484
|
/**
|
|
438
485
|
* @private
|
|
@@ -455,12 +502,13 @@ function asCast(maybeCast) {
|
|
|
455
502
|
* @param proxy
|
|
456
503
|
*/
|
|
457
504
|
function asProxyConfig(proxy) {
|
|
505
|
+
const proxyServer = proxy.server.trim();
|
|
458
506
|
// Playwright defaults to http when proxy.server does not define the protocol
|
|
459
507
|
// See https://playwright.dev/docs/api/class-testoptions#test-options-proxy
|
|
460
|
-
const hasProtocol =
|
|
508
|
+
const hasProtocol = /^[\dA-Za-z]+:\/\//.test(proxyServer);
|
|
461
509
|
const proxyUrl = hasProtocol
|
|
462
|
-
? new URL(
|
|
463
|
-
: new URL(`http://${
|
|
510
|
+
? new URL(proxyServer)
|
|
511
|
+
: new URL(`http://${proxyServer}`);
|
|
464
512
|
const host = proxyUrl.hostname;
|
|
465
513
|
const port = proxyUrl.port
|
|
466
514
|
? Number(proxyUrl.port)
|
package/lib/api/test-api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-api.js","sourceRoot":"","sources":["../../src/api/test-api.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
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AAQ,EAAC,SAAS,EAAE,IAAA,uBAAU,GAAE,CAAC,CAAC,CAAC;AAClF,CAAC;AAED;;;GAGG;AACH,SAAS,aAAa,CAAC,KAAqC;IAOxD,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IAExC,6EAA6E;IAC7E,2EAA2E;IAC3E,MAAM,WAAW,GAAG,mBAAmB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC1D,MAAM,QAAQ,GAAG,WAAW;QACxB,CAAC,CAAC,IAAI,GAAG,CAAC,WAAW,CAAC;QACtB,CAAC,CAAC,IAAI,GAAG,CAAC,UAAW,WAAY,EAAE,CAAC,CAAC;IAEzC,MAAM,IAAI,GAAG,QAAQ,CAAC,QAAQ,CAAC;IAC/B,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI;QACtB,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC,CAAC,SAAS,CAAC;IAChB,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ;QACvB,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,EAAE,EAAE;QAC9D,CAAC,CAAC,SAAS,CAAC;IAChB,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;IAE5B,OAAO;QACH,QAAQ,EAAE,QAAQ,CAAC,QAAQ;QAC3B,IAAI;QACJ,IAAI;QACJ,IAAI;QACJ,MAAM;KACT,CAAC;AACN,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serenity-js/playwright-test",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.37.0",
|
|
4
4
|
"description": "Serenity/JS test runner adapter for Playwright Test, combining Playwright's developer experience with the advanced reporting and automation capabilities of Serenity/JS",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Jan Molak",
|
|
@@ -59,10 +59,11 @@
|
|
|
59
59
|
"node": "^20 || ^22 || ^24"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@serenity-js/core": "3.
|
|
63
|
-
"@serenity-js/playwright": "3.
|
|
64
|
-
"@serenity-js/rest": "3.
|
|
65
|
-
"@serenity-js/web": "3.
|
|
62
|
+
"@serenity-js/core": "3.37.0",
|
|
63
|
+
"@serenity-js/playwright": "3.37.0",
|
|
64
|
+
"@serenity-js/rest": "3.37.0",
|
|
65
|
+
"@serenity-js/web": "3.37.0",
|
|
66
|
+
"axios": "1.13.2",
|
|
66
67
|
"deepmerge": "4.3.1",
|
|
67
68
|
"tiny-types": "1.24.3"
|
|
68
69
|
},
|
|
@@ -80,5 +81,5 @@
|
|
|
80
81
|
"ts-node": "10.9.2",
|
|
81
82
|
"typescript": "5.9.3"
|
|
82
83
|
},
|
|
83
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "dae146cd99a04f09b5926fb9d3205af562fa2927"
|
|
84
85
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type {
|
|
2
|
+
Ability,
|
|
3
|
+
Actor,
|
|
2
4
|
Cast,
|
|
3
5
|
ClassDescription,
|
|
4
6
|
Duration,
|
|
@@ -6,8 +8,9 @@ import type {
|
|
|
6
8
|
StageCrewMember,
|
|
7
9
|
StageCrewMemberBuilder
|
|
8
10
|
} from '@serenity-js/core';
|
|
9
|
-
import type { Actor } from '@serenity-js/core';
|
|
10
11
|
import type { ExtraBrowserContextOptions } from '@serenity-js/playwright';
|
|
12
|
+
import type { AxiosRequestConfigDefaults } from '@serenity-js/rest';
|
|
13
|
+
import { type AxiosInstance } from 'axios';
|
|
11
14
|
|
|
12
15
|
/**
|
|
13
16
|
* Serenity/JS-specific [Playwright Test fixtures](https://playwright.dev/docs/test-fixtures)
|
|
@@ -241,31 +244,92 @@ export interface SerenityFixtures {
|
|
|
241
244
|
*/
|
|
242
245
|
extraContextOptions: Partial<ExtraBrowserContextOptions>;
|
|
243
246
|
|
|
247
|
+
/**
|
|
248
|
+
* Extra abilities given to the actors on top of the default ones provided by the [`actors`](https://serenity-js.org/api/playwright-test/interface/SerenityFixtures/#actors) fixture.
|
|
249
|
+
*
|
|
250
|
+
* #### Extra abilities for all actors
|
|
251
|
+
*
|
|
252
|
+
* To give the same set of extra abilities to all the actors, make your `extraAbilities` fixture
|
|
253
|
+
* return an array of [`Ability`](https://serenity-js.org/api/core/class/Ability/) objects.
|
|
254
|
+
*
|
|
255
|
+
* ```typescript
|
|
256
|
+
* import { type Ability } from '@serenity-js/core';
|
|
257
|
+
* import { describe, it, test } from '@serenity-js/playwright-test';
|
|
258
|
+
* import { MyAbility } from './MyAbility';
|
|
259
|
+
*
|
|
260
|
+
* describe(`My feature`, () => {
|
|
261
|
+
*
|
|
262
|
+
* test.use({
|
|
263
|
+
* extraAbilities: [ new MyAbility() ]
|
|
264
|
+
* });
|
|
265
|
+
*
|
|
266
|
+
* it(`...`, async({ actor }) => {
|
|
267
|
+
* // ...
|
|
268
|
+
* });
|
|
269
|
+
* });
|
|
270
|
+
* ```
|
|
271
|
+
*
|
|
272
|
+
* #### Extra abilities for selected actors
|
|
273
|
+
*
|
|
274
|
+
* To give extra abilities only to selected actors, make your `extraAbilities` fixture return a `(actorName: string) => Ability[]` function that maps
|
|
275
|
+
* the actor name to an array of [`Ability`](https://serenity-js.org/api/core/class/Ability/) objects.
|
|
276
|
+
*
|
|
277
|
+
* ```typescript
|
|
278
|
+
* import { describe, it, test } from '@serenity-js/playwright-test';
|
|
279
|
+
* import { MyAbility } from './MyAbility';
|
|
280
|
+
*
|
|
281
|
+
* describe(`My feature`, () => {
|
|
282
|
+
*
|
|
283
|
+
* test.use({
|
|
284
|
+
* extraAbilities: async ({ }, use) => {
|
|
285
|
+
* await use((actorName: string) => {
|
|
286
|
+
* // Alice gets the extra abilities, but others don't
|
|
287
|
+
* return actorName === 'Alice'
|
|
288
|
+
* ? [ new MyAbility() ]
|
|
289
|
+
* : [];
|
|
290
|
+
* })
|
|
291
|
+
* }
|
|
292
|
+
* });
|
|
293
|
+
*
|
|
294
|
+
* it(`...`, async({ actor }) => {
|
|
295
|
+
* // ...
|
|
296
|
+
* });
|
|
297
|
+
* });
|
|
298
|
+
* ```
|
|
299
|
+
*/
|
|
300
|
+
extraAbilities: ((actorName: string) => Ability[]) | Ability[];
|
|
301
|
+
|
|
244
302
|
/**
|
|
245
303
|
* A cast of Serenity/JS actors to be used instead of the default cast
|
|
246
304
|
* when instantiating [`actor`](https://serenity-js.org/api/playwright-test/interface/SerenityFixtures/#actor)
|
|
247
305
|
* and invoking [`actorCalled`](https://serenity-js.org/api/playwright-test/interface/SerenityWorkerFixtures/#actorCalled).
|
|
248
306
|
*
|
|
249
307
|
* :::info Did you know?
|
|
250
|
-
*
|
|
251
|
-
*
|
|
252
|
-
*
|
|
253
|
-
* The default abilities should be sufficient in most web testing scenarios. However, you might want to override this default configuration
|
|
254
|
-
* when you need your actors to [interact with REST APIs](https://serenity-js.org/api/rest/class/CallAnApi/),
|
|
255
|
-
* [manage local servers](https://serenity-js.org/api/local-server/class/ManageALocalServer/),
|
|
256
|
-
* start with a notepad that has some [initial state](https://serenity-js.org/api/core/class/TakeNotes/#using),
|
|
257
|
-
* or receive [custom abilities](https://serenity-js.org/api/core/class/Ability/).
|
|
258
|
-
* :::
|
|
308
|
+
* Serenity/JS [test APIs](https://serenity-js.org/api/playwright-test/function/it/) offer fixtures that set up the default cast of actors for you,
|
|
309
|
+
* which should be sufficient in most web and HTTP API testing scenarios.
|
|
259
310
|
*
|
|
311
|
+
* Each one of the default actors receives the following [abilities](https://serenity-js.org/api/core/class/Ability/):
|
|
312
|
+
* - [`BrowseTheWebWithPlaywright`](https://serenity-js.org/api/playwright/class/BrowseTheWebWithPlaywright/), connected to Playwright [`page`](https://playwright.dev/docs/test-fixtures) fixture
|
|
313
|
+
* - [`TakeNotes`](https://serenity-js.org/api/core/class/TakeNotes/#usingAnEmptyNotepad)
|
|
314
|
+
* - [`CallAnApi`](https://serenity-js.org/api/rest/class/CallAnApi/), pointing at the [`baseURL`](https://playwright.dev/docs/test-use-options#basic-options)
|
|
315
|
+
* and using any `proxy` settings in your Playwright config file.
|
|
316
|
+
*
|
|
317
|
+
* The easiest way to give your actors additional abilities is to use the [`extraAbilities`](https://serenity-js.org/api/playwright-test/interface/SerenityFixtures/#extraAbilities) fixture.
|
|
318
|
+
* :::
|
|
260
319
|
*
|
|
261
320
|
* #### Overriding the default cast of Serenity/JS actors
|
|
262
321
|
*
|
|
263
322
|
* ```typescript
|
|
264
|
-
* import { Cast, TakeNotes } from '@serenity-js/core'
|
|
265
323
|
* import { Ensure, equals } from '@serenity-js/assertions'
|
|
324
|
+
* import { Cast, TakeNotes } from '@serenity-js/core'
|
|
266
325
|
* import { BrowseTheWebWithPlaywright } from '@serenity-js/playwright'
|
|
326
|
+
* import { CallAnApi } from '@serenity-js/rest'
|
|
267
327
|
* import { describe, it, test } from '@serenity-js/playwright-test'
|
|
268
328
|
*
|
|
329
|
+
* interface MyNotes {
|
|
330
|
+
* username: string;
|
|
331
|
+
* }
|
|
332
|
+
*
|
|
269
333
|
* describe(`Recording items`, () => {
|
|
270
334
|
*
|
|
271
335
|
* test.use({
|
|
@@ -273,17 +337,24 @@ export interface SerenityFixtures {
|
|
|
273
337
|
* defaultNavigationTimeout: 30_000,
|
|
274
338
|
* },
|
|
275
339
|
*
|
|
276
|
-
*
|
|
277
|
-
*
|
|
278
|
-
*
|
|
279
|
-
*
|
|
280
|
-
*
|
|
281
|
-
*
|
|
340
|
+
* actors: async ({ axios, extraAbilities, extraContextOptions, extraHTTPHeaders, page }, use) => {
|
|
341
|
+
* const cast = Cast.where(actor => {
|
|
342
|
+
* const abilities = Array.isArray(extraAbilities)
|
|
343
|
+
* ? extraAbilities
|
|
344
|
+
* : extraAbilities(actor.name);
|
|
345
|
+
*
|
|
346
|
+
* return actor.whoCan(
|
|
347
|
+
* BrowseTheWebWithPlaywright.usingPage(page, extraContextOptions),
|
|
348
|
+
* TakeNotes.using<MyNotes>(Notepad.with({
|
|
349
|
+
* username: 'example.username'
|
|
350
|
+
* }),
|
|
351
|
+
* CallAnApi.using(axios),
|
|
352
|
+
* ...abilities,
|
|
282
353
|
* )
|
|
283
|
-
* )
|
|
354
|
+
* })
|
|
284
355
|
*
|
|
285
356
|
* // Make sure to pass your custom cast to Playwright `use` callback
|
|
286
|
-
* await use(cast)
|
|
357
|
+
* await use(cast);
|
|
287
358
|
* },
|
|
288
359
|
* })
|
|
289
360
|
*
|
|
@@ -322,6 +393,18 @@ export interface SerenityFixtures {
|
|
|
322
393
|
* - Declaring a Serenity/JS [test scenario](https://serenity-js.org/api/playwright-test/function/it/)
|
|
323
394
|
*/
|
|
324
395
|
actor: Actor;
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* An instance of the Axios HTTP client, or default Axios request configurations,
|
|
399
|
+
* to be used by the [`CallAnApi`](https://serenity-js.org/api/rest/class/CallAnApi/) ability,
|
|
400
|
+
* provided to the actors via the [`actors`](https://serenity-js.org/api/playwright-test/interface/SerenityFixtures/#actors) fixture.
|
|
401
|
+
*
|
|
402
|
+
* By default, Serenity/JS configures Axios to use the following settings from your Playwright configuration file:
|
|
403
|
+
* - [`baseURL`](https://playwright.dev/docs/api/class-testoptions#test-options-base-url)
|
|
404
|
+
* - [`proxy`](https://playwright.dev/docs/api/class-testoptions#test-options-proxy)
|
|
405
|
+
* - [`extraHTTPHeaders`](https://playwright.dev/docs/api/class-testoptions#test-options-extra-http-headers)
|
|
406
|
+
*/
|
|
407
|
+
axios: AxiosInstance | AxiosRequestConfigDefaults;
|
|
325
408
|
}
|
|
326
409
|
|
|
327
410
|
/**
|
|
@@ -370,7 +453,9 @@ export interface SerenityWorkerFixtures {
|
|
|
370
453
|
serenity: Serenity;
|
|
371
454
|
|
|
372
455
|
/**
|
|
373
|
-
* Uses the provided [cast](https://serenity-js.org/api/core/class/Cast/) of
|
|
456
|
+
* Uses the provided [cast](https://serenity-js.org/api/core/class/Cast/) of
|
|
457
|
+
* [`actors`](https://serenity-js.org/api/playwright-test/interface/SerenityFixtures/#actors) to instantiate
|
|
458
|
+
* an [`Actor`](https://serenity-js.org/api/core/class/Actor/) called `name`
|
|
374
459
|
* and inject it into a [test scenario](https://serenity-js.org/api/playwright-test/function/it/).
|
|
375
460
|
*
|
|
376
461
|
* Retrieves an existing actor if one has already been instantiated.
|