Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion src/matchers/element/toBeDisplayed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,38 @@
import { DEFAULT_OPTIONS } from '../../constants.js'
import type { WdioElementMaybePromise } from '../../types.js'

interface ToBeDisplayedOptions {
/**
* `true` to check if the element is within the viewport. false by default.
*/
withinViewport?: boolean
/**
* `true` to check if the element content-visibility property has (or inherits) the value auto,
* and it is currently skipping its rendering. `true` by default.
* @default true
*/
contentVisibilityAuto?: boolean
/**
* `true` to check if the element opacity property has (or inherits) a value of 0. `true` by default.
* @default true
*/
opacityProperty?: boolean
/**
* `true` to check if the element is invisible due to the value of its visibility property. `true` by default.
* @default true
*/
visibilityProperty?: boolean
}

export async function toBeDisplayed(
received: WdioElementMaybePromise,
options: ExpectWebdriverIO.CommandOptions = DEFAULT_OPTIONS
options: ExpectWebdriverIO.CommandOptions & ToBeDisplayedOptions = DEFAULT_OPTIONS
) {
options.withinViewport ??= false;

Check failure on line 32 in src/matchers/element/toBeDisplayed.ts

View workflow job for this annotation

GitHub Actions / linux (22.x)

Extra semicolon

Check failure on line 32 in src/matchers/element/toBeDisplayed.ts

View workflow job for this annotation

GitHub Actions / linux (20.x)

Extra semicolon

Check failure on line 32 in src/matchers/element/toBeDisplayed.ts

View workflow job for this annotation

GitHub Actions / linux (18.x)

Extra semicolon
options.contentVisibilityAuto ??= true;

Check failure on line 33 in src/matchers/element/toBeDisplayed.ts

View workflow job for this annotation

GitHub Actions / linux (22.x)

Extra semicolon

Check failure on line 33 in src/matchers/element/toBeDisplayed.ts

View workflow job for this annotation

GitHub Actions / linux (20.x)

Extra semicolon

Check failure on line 33 in src/matchers/element/toBeDisplayed.ts

View workflow job for this annotation

GitHub Actions / linux (18.x)

Extra semicolon
options.opacityProperty ??= true;

Check failure on line 34 in src/matchers/element/toBeDisplayed.ts

View workflow job for this annotation

GitHub Actions / linux (22.x)

Extra semicolon

Check failure on line 34 in src/matchers/element/toBeDisplayed.ts

View workflow job for this annotation

GitHub Actions / linux (20.x)

Extra semicolon

Check failure on line 34 in src/matchers/element/toBeDisplayed.ts

View workflow job for this annotation

GitHub Actions / linux (18.x)

Extra semicolon
options.visibilityProperty ??= true;

Check failure on line 35 in src/matchers/element/toBeDisplayed.ts

View workflow job for this annotation

GitHub Actions / linux (22.x)

Extra semicolon

Check failure on line 35 in src/matchers/element/toBeDisplayed.ts

View workflow job for this annotation

GitHub Actions / linux (20.x)

Extra semicolon

Check failure on line 35 in src/matchers/element/toBeDisplayed.ts

View workflow job for this annotation

GitHub Actions / linux (18.x)

Extra semicolon

this.expectation = this.expectation || 'displayed'

await options.beforeAssertion?.({
Expand Down
Loading