Skip to main content

q

Callable


  • A Serenity/JS Screenplay Pattern-flavour of a tagged template literal, q is a tag function capable of resolving any Answerable<string> or Answerable<number> you parametrise it with, and returning a QuestionAdapter<string>.

    Use q to concatenate string and number values returned from synchronous an asynchronous sources.

    Interpolating questions

    import { q, actorCalled } from '@serenity-js/core'
    import { Send, DeleteRequest } from '@serenity-js/rest'
    import { Text } from '@serenity-js/web'

    await actorCalled('Alice').attemptsTo(
    Send.a(DeleteRequest.to(
    q `/articles/${ Text.of(Article.id()) }`
    ))
    )

    Using a custom description

    import { q, actorCalled } from '@serenity-js/core'
    import { Send, DeleteRequest } from '@serenity-js/rest'

    await actorCalled('Alice').attemptsTo(
    Send.a(DeleteRequest.to(
    q `/articles/${ Text.of(Article.id()) }`.describedAs('/articles/:id')
    ))
    )

    Transforming the interpolated string

    The mechanism presented below relies on QuestionAdapter.

    import { q, actorCalled } from '@serenity-js/core'
    import { Send, DeleteRequest } from '@serenity-js/rest'

    await actorCalled('Alice').attemptsTo(
    Send.a(DeleteRequest.to(
    q `/articles/${ Text.of(Article.id()) }`.toLocaleLowerCase()
    ))
    )

    Learn more


    Parameters

    • templates: TemplateStringsArray
    • rest...parameters: Answerable<string | number>[]

    Returns QuestionAdapter<string>