From 2c78e9d12cd510e619fbe816cdadb55c90461cc2 Mon Sep 17 00:00:00 2001 From: Mark Date: Mon, 4 Dec 2023 20:18:05 -0500 Subject: [PATCH] feat(assertions): add "Then I see element exists" --- src/assertions/exist.ts | 33 +++++++++++++++++++++++++++++++++ src/assertions/index.ts | 1 + 2 files changed, 34 insertions(+) create mode 100644 src/assertions/exist.ts diff --git a/src/assertions/exist.ts b/src/assertions/exist.ts new file mode 100644 index 000000000..a06374e7a --- /dev/null +++ b/src/assertions/exist.ts @@ -0,0 +1,33 @@ +import { Then } from '@badeball/cypress-cucumber-preprocessor'; + +import { getCypressElement } from '../utils'; + +/** + * Then I see element exists: + * + * ```gherkin + * Then I see element exists + * ``` + * + * Assert element **_exists_** in the screen. + * + * @example + * + * ```gherkin + * Then I see element exists + * ``` + * + * @remarks + * + * A preceding step like {@link When_I_find_element_by_text | "When I find element by text"} is required. For example: + * + * ```gherkin + * When I find element by text "Text" + * Then I see element exists + * ``` + */ +export function Then_I_see_element_exists() { + getCypressElement().should('exist'); +} + +Then('I see element exists', Then_I_see_element_exists); diff --git a/src/assertions/index.ts b/src/assertions/index.ts index d5bc07a4a..99ff44de0 100644 --- a/src/assertions/index.ts +++ b/src/assertions/index.ts @@ -3,6 +3,7 @@ export * from './button'; export * from './cookie'; export * from './count'; export * from './document-title'; +export * from './exist'; export * from './hash'; export * from './heading'; export * from './label';