externaluseBase
Callable
Type parameters
- BaseTestFixtures: PlaywrightTestArgs & PlaywrightTestOptions
- BaseWorkerFixtures: PlaywrightWorkerArgs & PlaywrightWorkerOptions
Parameters
externalbaseTest: TestType<BaseTestFixtures, BaseWorkerFixtures>
Returns TestApi<BaseTestFixtures & SerenityFixtures, BaseWorkerFixtures & SerenityWorkerFixtures>
Creates a Serenity/JS BDD-style test API around the given Playwright base test.
Using default configuration
When your test scenario doesn't require custom test fixtures, and you're happy with the default base test offered by Playwright, you can import test API functions such as
describeanditdirectly from@serenity-js/playwright-test.In the above example, importing test API functions directly from
@serenity-js/playwright-testis the equivalent of the following setup:Using custom fixtures
When your test scenario requires custom test fixtures, but you're still happy with the default base test offered by Playwright, you can create fixture-aware test API functions such as
describeanditby callinguseFixtures.For example, you can create a test scenario using a static
messagefixture as follows:The value of your test fixtures can be either static or dynamic and based on the value of other fixtures.
To create a dynamic test fixture use the function syntax:
In the above example, creating test API functions via
useFixturesis the equivalent of the following setup:Using custom base test
In cases where you need to use a non-default base test, for example when doing UI component testing, you can create Serenity/JS test API functions around your preferred base test.