Skip to main content

useFixtures

Callable

  • useFixtures<T, W>(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>

  • Creates a Serenity/JS BDD-style test API around the default Playwright base test and using custom test fixtures.

    import { useFixtures } from '@serenity-js/playwright-test'
    import { Log } from '@serenity-js/core'

    const { describe, it } = useFixtures<{ message: string }>({
    message: 'Hello world!'
    })

    describe('Serenity/JS useFixtures', () => {

    it('enables injecting custom test fixtures into test scenarios', async ({ actor, message }) => {
    await actor.attemptsTo(
    Log.the(message),
    )
    })
    })

    Shorthand for useBase


    Type parameters

    • T: Record<string, any>
    • W: Record<string, any> = object

    Parameters

    • customFixtures: Fixtures<T, W, PlaywrightTestArgs & PlaywrightTestOptions & Omit<SerenityOptions, actors> & SerenityFixtures, PlaywrightWorkerArgs & PlaywrightWorkerOptions & object>

    Returns TestApi<PlaywrightTestArgs & PlaywrightTestOptions & Omit<SerenityOptions, actors> & SerenityFixtures & T, PlaywrightWorkerArgs & PlaywrightWorkerOptions & object & W>