Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow for checking non-existent elements #1623

Merged
merged 2 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion src/matchers/element/toHaveAttribute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export async function toHaveAttributeAndValue(received: ChainablePromiseElement,
const isNot = this.isNot
const { expectation = 'attribute', verb = 'have' } = this

let el = await received.getElement()
let el = await received?.getElement()
let attr
const pass = await waitUntil(async () => {
const result = await executeCommand.call(this, el, conditionAttrAndValue, options, [attribute, value, options])
Expand Down
2 changes: 1 addition & 1 deletion src/matchers/element/toHaveChildren.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export async function toHaveChildren(
? { eq: expectedValue } as ExpectWebdriverIO.NumberOptions
: expectedValue || {}

let el = await received.getElement()
let el = await received?.getElement()
let children
const pass = await waitUntil(async () => {
const result = await executeCommand.call(this, el, condition, numberOptions, [numberOptions])
Expand Down
2 changes: 1 addition & 1 deletion src/matchers/element/toHaveClass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export async function toHaveElementClass(

const attribute = 'class'

let el = await received.getElement()
let el = await received?.getElement()
let attr

const pass = await waitUntil(async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/matchers/element/toHaveComputedLabel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export async function toHaveComputedLabel(
options,
})

let el = await received.getElement()
let el = await received?.getElement()
let actualLabel

const pass = await waitUntil(
Expand Down
2 changes: 1 addition & 1 deletion src/matchers/element/toHaveComputedRole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export async function toHaveComputedRole(
options,
})

let el = await received.getElement()
let el = await received?.getElement()
let actualRole

const pass = await waitUntil(
Expand Down
2 changes: 1 addition & 1 deletion src/matchers/element/toHaveElementProperty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export async function toHaveElementProperty(
options,
})

let el = await received.getElement()
let el = await received?.getElement()
let prop: any
const pass = await waitUntil(
async () => {
Expand Down
4 changes: 2 additions & 2 deletions src/matchers/element/toHaveHTML.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ export async function toHaveHTML(
})

let el = 'getElement' in received
? await received.getElement()
? await received?.getElement()
: 'getElements' in received
? await received.getElements()
? await received?.getElements()
: received
let actualHTML

Expand Down
2 changes: 1 addition & 1 deletion src/matchers/element/toHaveHeight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export async function toHaveHeight(
options,
})

let el = await received.getElement()
let el = await received?.getElement()
let actualHeight

const pass = await waitUntil(
Expand Down
2 changes: 1 addition & 1 deletion src/matchers/element/toHaveSize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export async function toHaveSize(
options,
})

let el = await received.getElement()
let el = await received?.getElement()
let actualSize

const pass = await waitUntil(
Expand Down
2 changes: 1 addition & 1 deletion src/matchers/element/toHaveStyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export async function toHaveStyle(
options,
})

let el = await received.getElement()
let el = await received?.getElement()
let actualStyle

const pass = await waitUntil(async () => {
Expand Down
4 changes: 2 additions & 2 deletions src/matchers/element/toHaveText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ export async function toHaveText(
})

let el = 'getElement' in received
? await received.getElement()
? await received?.getElement()
: 'getElements' in received
? await received.getElements()
? await received?.getElements()
: received
let actualText

Expand Down
2 changes: 1 addition & 1 deletion src/matchers/element/toHaveWidth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export async function toHaveWidth(
options,
})

let el = await received.getElement()
let el = await received?.getElement()
let actualWidth

const pass = await waitUntil(
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ async function executeCommandBe(
): Promise<ExpectWebdriverIO.AssertionResult> {
const { isNot, expectation, verb = 'be' } = this

let el = await received.getElement()
let el = await received?.getElement()
const pass = await waitUntil(
async () => {
const result = await executeCommand.call(
Expand Down
Loading