Skip to main content

Debug <Values>

Instructs the actor to evaluate and log the provided Answerable values.

Since this interaction accepts a callback function that receives the evaluated results, the best way to use it is while running the test scenario via a Node.js debugger. See the links below to learn how to do it in popular IDEs.

Debugging Answerable values

Debug.values accepts a callback function that receives an array of DebuggingResult objects, as well as the result of evaluating each provided answerable with Actor.answer.

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

// Running the below through the Node.js debugger makes the actor resolve the provided values
// and return them to the debugger function, where you can investigate their contents,
// or inspect any Errors the evaluation has resulted with.
await actorCalled('Debbie').attemptsTo(
Navigate.to('http://example.org'),
Debug.values((results, title, url) => {
// set a breakpoint here to view `results`, `title` and `url` in your IDE debugger
}, Page.current().title(), Page.current().url()), // accepts multiple values
);

Accessing Playwright Page

Playwright Test for VSCode provides features that allow for experimenting with web UI locators while the test is paused at breakpoint.

Since this functionality is specific to Playwright, you can use it by passing PlaywrightPage.current().nativePage() to Serenity/JS Debug.values. Also make sure to name the evaluated value page, as this is the variable name that the Playwright VSCode extension expects.

import { actorCalled, Debug } from '@serenity-js/core'
import { PlaywrightPage } from '@serenity-js/playwright'

// Running the below through the Node.js debugger makes the actor resolve the provided values
// and return them to the debugger function, where you can investigate their contents,
// or inspect any Errors the evaluation has resulted with.
await actorCalled('Debbie').attemptsTo(
Navigate.to('http://example.org'),
Debug.values((results, page) => {
// set a breakpoint here to use Playwright locator debugging features
page.locator('.example-css-class')
// note that you can change this selector while having the test paused at breakpoint
}, PlaywrightPage.current().nativePage()),
);

Learn more

Hierarchy

Index

Methods

staticvalues

  • values<Values>(debuggerFunction: (results: { [ Index in string | number | symbol ]: DebuggingResult<Values[Index]> }, ...answers: { [ Index in string | number | symbol ]: Answered<Values[Index]> }) => void | Promise<void>, ...values: Values): Interaction
  • Instructs the actor to evaluate the provided values, log the results, and then pass them to your debuggerFunction.

    To use this interaction, run your test scenario in the Node.js debugger and set a breakpoint inside the debuggerFunction.


    Type parameters

    • Values: unknown[]

    Parameters

    • debuggerFunction: (results: { [ Index in string | number | symbol ]: DebuggingResult<Values[Index]> }, ...answers: { [ Index in string | number | symbol ]: Answered<Values[Index]> }) => void | Promise<void>
    • rest...values: Values

    Returns Interaction

instantiationLocation

  • instantiationLocation(): FileSystemLocation
  • Returns the location where this Activity was instantiated.


    Returns FileSystemLocation

toString

  • toString(): string
  • Generates a human-friendly description to be used when reporting this Activity.

    Note: When this activity is reported, token #actor in the description will be replaced with the name of the actor performing this Activity.

    For example, #actor clicks on a button becomes Wendy clicks on a button.


    Returns string

performAs