Skip to main content

format

Callable

  • format(config: { markQuestions: boolean }): (templates: TemplateStringsArray, ...placeholders: Answerable<any>[]) => string

  • format is a factory function returning a tag function that produces a human-readable description of a template containing one or more Answerables.

    Typically, you’ll want to use d and f shorthands instead:

    • the d function works best for generating a description of a parameterised Activity
    • the f function is better suited for debugging.

    Using format

    import { format, Question } from '@serenity-js/core'

    const someQuestion = () =>
    Question.about('some question', actor => 'some value')

    format({ markQuestions: true }) `actor answers ${ question() }`
    // returns: actor answers <<some question>>

    format({ markQuestions: false }) `actor answers ${ question() }`
    // returns: actor answers some question

    Using d

    import { d, Question } from '@serenity-js/core'

    const someQuestion = () =>
    Question.about('some question', actor => 'some value')

    d`actor answers ${ question() }`
    // returns: actor answers <<some question>>

    Using f

    import { f, Question } from '@serenity-js/core'

    const someQuestion = () =>
    Question.about('some question', actor => 'some value')

    f`actor answers ${ question() }`
    // returns: actor answers <<some question>>

    format({ markQuestions: false }) `actor answers ${ question() }`
    // returns: actor answers <<some question>>

    Parameters

    • config: { markQuestions: boolean }

      markQuestions: boolean - if set to true, descriptions of questions passed in as arguments will be surrounded with double angled brackets, i.e. <<description>>

    Returns (templates: TemplateStringsArray, ...placeholders: Answerable<any>[]) => string

      • (templates: TemplateStringsArray, ...placeholders: Answerable<any>[]): string
      • Parameters

        • templates: TemplateStringsArray
        • rest...placeholders: Answerable<any>[]

        Returns string