Skip to main content

externalDebug <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

staticexternalvalues

  • values<Values>(debuggerFunction: (results: { [ Index in string | number | symbol ]: DebuggingResult<Values[Index<Index>]> }, ...answers: { [ Index in string | number | symbol ]: Answered<Values[Index<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

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

    Returns Interaction

externalinstantiationLocation

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


    Returns FileSystemLocation

externalperformAs

externaldescribedBy

  • Resolves the description of this object in the context of the provided actor.


    Parameters

    Returns Promise<string>

externaltoString

  • toString(): string
  • Returns a human-readable description of this object.


    Returns string