Skip to content

Assertion Steps

Beginners: start with Viewing Reports or Creating Tests if you still need the workflow context first. This page is the exact assertion-step reference.

Source: src/tests/steps/validations/*.step.ts.

See shared placeholder rules in Step Parameter Conventions.

Prefer installing published steps with npx appraisejs@latest add step ... instead of adding the package to your project with npm install.

Use assertion steps when the scenario must validate page text, element state, or route state after an action.

the element {string} should {boolean} contain the text {string}

Terminal window
npx appraisejs@latest add step text-assertion/assert-element-contains-text
  • Resolves locator.
  • Reads textContent().
  • Asserts contains or does-not-contain based on boolean flag.
ParameterRepresentsExpected data
First {string}Element locator nameExisting locator key (for example toastMessage).
{boolean}Positive or negative assertiontrue for must contain, false for must not contain.
Second {string}Target textExpected literal/partial text value.
Then the element "toastMessage" should true contain the text "Saved successfully"

the element {string} should {boolean} equal the text {string}

Terminal window
npx appraisejs@latest add step text-assertion/assert-element-equals-text
  • Resolves locator.
  • Reads textContent().
  • Asserts exact equality or inequality based on boolean flag.
ParameterRepresentsExpected data
First {string}Element locator nameExisting locator key (for example pageTitle).
{boolean}Positive or negative assertiontrue for must equal, false for must not equal.
Second {string}Expected exact textExact value expected in element.
Then the element "pageTitle" should true equal the text "Dashboard"

the visibility status of the {string} element should be {boolean}

Terminal window
npx appraisejs@latest add step visibility-assertion/assert-element-visible
  • Resolves locator.
  • Uses Playwright visibility check.
  • Asserts visible/non-visible state.
ParameterRepresentsExpected data
{string}Element locator nameExisting locator key.
{boolean}Expected visibilitytrue for visible, false for hidden/not visible.
Then the visibility status of the "successBanner" element should be true

the element {string} should have active status {boolean}

Terminal window
npx appraisejs@latest add step active-state-assertion/assert-element-active
  • Resolves locator.
  • Uses Playwright enabled-state check.
  • Asserts enabled/disabled expectation.
ParameterRepresentsExpected data
{string}Element locator nameExisting locator key.
{boolean}Expected active statetrue for active/enabled, false for not active/disabled.
Then the element "submitButton" should have active status true

the url route should be equal to {string}

Terminal window
npx appraisejs@latest add step navigation-assertion/assert-url-route-equals
  • Waits for network idle.
  • Extracts current pathname from URL.
  • Compares pathname to expected route.
ParameterRepresentsExpected data
{string}Expected pathnameRoute path (for example /dashboard).
Then the url route should be equal to "/dashboard"
  • Assertions fail when the locator is missing, the expected state is wrong, or the page has not reached the required state yet.
  • Route assertions can fail when the environment or navigation step did not land where you expected.

The signature below exists but is currently stubbed (no implementation body):

  • the element {string} should contain the text inside the stored variable {string}
  • Install with CLI: npx appraisejs@latest add step text-assertion/assert-element-contains-stored-variable-text