@serenity-js/playwright-test
Advanced tools
Comparing version 3.10.2 to 3.10.3
@@ -6,2 +6,14 @@ # Change Log | ||
## [3.10.3](https://github.com/serenity-js/serenity-js/compare/v3.10.2...v3.10.3) (2023-09-15) | ||
### Bug Fixes | ||
* **deps:** update playwright dependencies to ^1.38.0 ([0b8074b](https://github.com/serenity-js/serenity-js/commit/0b8074b19155a38aa2009049d9a395b7026d12b3)) | ||
* **playwright-test:** simplified and documented implementing custom Playwright Test fixtures ([61fc2bc](https://github.com/serenity-js/serenity-js/commit/61fc2bce72c9758658851949afac84d573698677)), closes [microsoft/playwright#24146](https://github.com/microsoft/playwright/issues/24146) | ||
## [3.10.2](https://github.com/serenity-js/serenity-js/compare/v3.10.1...v3.10.2) (2023-09-10) | ||
@@ -8,0 +20,0 @@ |
@@ -0,5 +1,7 @@ | ||
export * from './DescribeFunction'; | ||
export * from './PlaywrightTestConfig'; | ||
export * from './SerenityFixtures'; | ||
export * from './SerenityOptions'; | ||
export * from './SuiteFunction'; | ||
export * from './test-api'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -17,6 +17,8 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./DescribeFunction"), exports); | ||
__exportStar(require("./PlaywrightTestConfig"), exports); | ||
__exportStar(require("./SerenityFixtures"), exports); | ||
__exportStar(require("./SerenityOptions"), exports); | ||
__exportStar(require("./SuiteFunction"), exports); | ||
__exportStar(require("./test-api"), exports); | ||
//# sourceMappingURL=index.js.map |
import type { Fixtures, PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions, TestInfo, TestType } from '@playwright/test'; | ||
import { test as playwrightBaseTest } from '@playwright/test'; | ||
import type { DescribeFunction } from './DescribeFunction'; | ||
import type { SerenityFixtures } from './SerenityFixtures'; | ||
@@ -37,3 +37,3 @@ import type { SerenityOptions } from './SerenityOptions'; | ||
test: TestType<TestArgs, WorkerArgs>; | ||
describe: typeof playwrightBaseTest.describe; | ||
describe: DescribeFunction; | ||
}; | ||
@@ -150,7 +150,19 @@ /** | ||
*/ | ||
export declare const describe: typeof playwrightBaseTest.describe; | ||
export declare const beforeAll: (inner: (args: PlaywrightTestArgs & PlaywrightTestOptions & Omit<SerenityOptions, "actors"> & SerenityFixtures & PlaywrightWorkerArgs & PlaywrightWorkerOptions & object, testInfo: TestInfo) => any) => void; | ||
export declare const beforeEach: (inner: (args: PlaywrightTestArgs & PlaywrightTestOptions & Omit<SerenityOptions, "actors"> & SerenityFixtures & PlaywrightWorkerArgs & PlaywrightWorkerOptions & object, testInfo: TestInfo) => any) => void; | ||
export declare const afterEach: (inner: (args: PlaywrightTestArgs & PlaywrightTestOptions & Omit<SerenityOptions, "actors"> & SerenityFixtures & PlaywrightWorkerArgs & PlaywrightWorkerOptions & object, testInfo: TestInfo) => any) => void; | ||
export declare const afterAll: (inner: (args: PlaywrightTestArgs & PlaywrightTestOptions & Omit<SerenityOptions, "actors"> & SerenityFixtures & PlaywrightWorkerArgs & PlaywrightWorkerOptions & object, testInfo: TestInfo) => any) => void; | ||
export declare const describe: DescribeFunction; | ||
export declare const beforeAll: { | ||
(inner: (args: PlaywrightTestArgs & PlaywrightTestOptions & Omit<SerenityOptions, "actors"> & SerenityFixtures & PlaywrightWorkerArgs & PlaywrightWorkerOptions & object, testInfo: TestInfo) => any): void; | ||
(title: string, inner: (args: PlaywrightTestArgs & PlaywrightTestOptions & Omit<SerenityOptions, "actors"> & SerenityFixtures & PlaywrightWorkerArgs & PlaywrightWorkerOptions & object, testInfo: TestInfo) => any): void; | ||
}; | ||
export declare const beforeEach: { | ||
(inner: (args: PlaywrightTestArgs & PlaywrightTestOptions & Omit<SerenityOptions, "actors"> & SerenityFixtures & PlaywrightWorkerArgs & PlaywrightWorkerOptions & object, testInfo: TestInfo) => any): void; | ||
(title: string, inner: (args: PlaywrightTestArgs & PlaywrightTestOptions & Omit<SerenityOptions, "actors"> & SerenityFixtures & PlaywrightWorkerArgs & PlaywrightWorkerOptions & object, testInfo: TestInfo) => any): void; | ||
}; | ||
export declare const afterEach: { | ||
(inner: (args: PlaywrightTestArgs & PlaywrightTestOptions & Omit<SerenityOptions, "actors"> & SerenityFixtures & PlaywrightWorkerArgs & PlaywrightWorkerOptions & object, testInfo: TestInfo) => any): void; | ||
(title: string, inner: (args: PlaywrightTestArgs & PlaywrightTestOptions & Omit<SerenityOptions, "actors"> & SerenityFixtures & PlaywrightWorkerArgs & PlaywrightWorkerOptions & object, testInfo: TestInfo) => any): void; | ||
}; | ||
export declare const afterAll: { | ||
(inner: (args: PlaywrightTestArgs & PlaywrightTestOptions & Omit<SerenityOptions, "actors"> & SerenityFixtures & PlaywrightWorkerArgs & PlaywrightWorkerOptions & object, testInfo: TestInfo) => any): void; | ||
(title: string, inner: (args: PlaywrightTestArgs & PlaywrightTestOptions & Omit<SerenityOptions, "actors"> & SerenityFixtures & PlaywrightWorkerArgs & PlaywrightWorkerOptions & object, testInfo: TestInfo) => any): void; | ||
}; | ||
export declare const expect: import("@playwright/test").Expect; | ||
@@ -157,0 +169,0 @@ export declare const useFixtures: <T extends Record<string, any>, W extends Record<string, any> = object>(customFixtures: Fixtures<T, W, PlaywrightTestArgs & PlaywrightTestOptions & Omit<SerenityOptions, "actors"> & SerenityFixtures, PlaywrightWorkerArgs & PlaywrightWorkerOptions & object>) => TestApi<PlaywrightTestArgs & PlaywrightTestOptions & Omit<SerenityOptions, "actors"> & SerenityFixtures & T, PlaywrightWorkerArgs & PlaywrightWorkerOptions & object & W>; |
{ | ||
"name": "@serenity-js/playwright-test", | ||
"version": "3.10.2", | ||
"version": "3.10.3", | ||
"description": "Serenity/JS reporter and test APIs for Playwright Test", | ||
@@ -47,6 +47,6 @@ "author": { | ||
"dependencies": { | ||
"@playwright/test": "^1.37.1", | ||
"@serenity-js/core": "3.10.2", | ||
"@serenity-js/playwright": "3.10.2", | ||
"@serenity-js/web": "3.10.2", | ||
"@playwright/test": "^1.38.0", | ||
"@serenity-js/core": "3.10.3", | ||
"@serenity-js/playwright": "3.10.3", | ||
"@serenity-js/web": "3.10.3", | ||
"deepmerge": "^4.3.1", | ||
@@ -65,3 +65,3 @@ "tiny-types": "^1.20.0" | ||
}, | ||
"gitHead": "6834827fffe5dd8dd3d2f39d2fea2c4039ab1d3d" | ||
"gitHead": "064edb63e8d4dee447feaab63cf61cbcf6414fdf" | ||
} |
@@ -231,2 +231,56 @@ # Serenity/JS | ||
#### Customising test fixtures | ||
[`useFixtures`](https://serenity-js.org/api/playwright-test/function/useFixtures/) lets you configure | ||
Serenity/JS Screenplay Pattern actors in a single place, | ||
and define custom [test fixtures](https://playwright.dev/docs/test-fixtures) if needed. | ||
```typescript | ||
// my-custom-api.ts | ||
export const { | ||
describe, it, test, beforeAll, beforeEach, afterEach, afterAll, expect | ||
} = useFixtures<{ email: string }>({ | ||
// Override Serenity/JS fixtures: | ||
actors: async ({ browser, baseURL }, use) => { | ||
await use( | ||
Cast.where(actor => actor.whoCan( | ||
BrowseTheWebWithPlaywright.using(browser), | ||
TakeNotes.usingAnEmptyNotepad(), | ||
CallAnApi.at(baseURL), | ||
)) | ||
) | ||
}, | ||
// Add your own fixtures: | ||
email: async ({ actor }, use) => { | ||
await use(`${ actor.name }@example.org`); | ||
}, | ||
}) | ||
``` | ||
With the custom test API definition in place, use it in your test files instead of the default one: | ||
```typescript | ||
// example.spec.ts | ||
import { Log } from '@serenity-js/core' | ||
import { describe, it, test } from './my-custom-api' // Note the custom test API | ||
describe('Serenity Screenplay with Playwright', () => { | ||
describe('New Todo', () => { | ||
// inject default actor: | ||
it('should allow me to add todo items', async ({ actor, email }) => { | ||
// define test workflow | ||
await actor.attemptsTo( | ||
Log.the(email), | ||
) | ||
}) | ||
}) | ||
}) | ||
``` | ||
### UI Component Testing | ||
@@ -233,0 +287,0 @@ |
@@ -0,4 +1,6 @@ | ||
export * from './DescribeFunction'; | ||
export * from './PlaywrightTestConfig'; | ||
export * from './SerenityFixtures'; | ||
export * from './SerenityOptions'; | ||
export * from './SuiteFunction'; | ||
export * from './test-api'; |
@@ -10,3 +10,3 @@ import type { | ||
} from '@playwright/test'; | ||
import { test as playwrightBaseTest, } from '@playwright/test'; | ||
import { test as playwrightBaseTest } from '@playwright/test'; | ||
import { AnsiDiffFormatter, Cast, Duration, serenity as serenityInstance, TakeNotes } from '@serenity-js/core'; | ||
@@ -26,2 +26,3 @@ import { SceneFinishes, SceneTagged } from '@serenity-js/core/lib/events'; | ||
} from '../reporter'; | ||
import type { DescribeFunction } from './DescribeFunction'; | ||
import { PerformActivitiesAsPlaywrightSteps } from './PerformActivitiesAsPlaywrightSteps'; | ||
@@ -190,3 +191,3 @@ import type { SerenityFixtures } from './SerenityFixtures'; | ||
test: TestType<TestArgs, WorkerArgs>, | ||
describe: typeof playwrightBaseTest.describe, | ||
describe: DescribeFunction, | ||
} | ||
@@ -324,3 +325,3 @@ | ||
*/ | ||
export const describe: typeof playwrightBaseTest.describe = api.describe; | ||
export const describe = api.describe; | ||
@@ -327,0 +328,0 @@ export const beforeAll = api.beforeAll; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
213375
76
3489
414
+ Added@noble/hashes@1.6.1(transitive)
+ Added@serenity-js/assertions@3.10.3(transitive)
+ Added@serenity-js/core@3.10.3(transitive)
+ Added@serenity-js/playwright@3.10.3(transitive)
+ Added@serenity-js/web@3.10.3(transitive)
- Removed@noble/hashes@1.6.0(transitive)
- Removed@serenity-js/assertions@3.10.2(transitive)
- Removed@serenity-js/core@3.10.2(transitive)
- Removed@serenity-js/playwright@3.10.2(transitive)
- Removed@serenity-js/web@3.10.2(transitive)
Updated@playwright/test@^1.38.0
Updated@serenity-js/core@3.10.3
Updated@serenity-js/web@3.10.3