Skip to main content

Logging

Serenity/JS helps you model your test scenarios from the perspective of actors performing activities to accomplish their goals. Logging follows this same consistent approach, with any log statements expressed using the interaction to Log.

The interaction to Log accepts any number of arguments, including dynamic values such as questions and question adapters:

import { actorCalled, Log } from '@serenity-js/core'
import { Page } from '@serenity-js/web'

await actorCalled('Laura').attemptsTo(
Log.the('Current page', Page.current().title(), Page.current().url().href),
// static value --^ question --^ question adapter --^
)

When the actor reaches the interaction to Log in their workflow, the interaction:

  • evaluates the arguments in the context of the given actor,
  • makes the actor collect data artifacts with the results of the evaluation,
  • the actor emits collected artifacts as domain events,
  • domain events are announced to all the registered Serenity/JS reporting services.

Since the interaction to Log relies on Serenity/JS domain events to propagate the information, all the registered reporting services receive the exact same information and can include it in their respective reports.