Skip to content

Commit 5a1ffe9

Browse files
committed
Code review
1 parent 1ab8f3d commit 5a1ffe9

File tree

7 files changed

+8
-12
lines changed

7 files changed

+8
-12
lines changed

src/matchers/element/toHaveAttribute.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ async function toHaveAttributeFn(received: WdioElementOrArrayMaybePromise, attri
8282
}
8383
}
8484

85-
// TODO we should have overload signature one with value and ExpectWebdriverIO.StringOptions, the other with no value and commnad options
85+
// TODO: one day it would be better to have overload signature one with value and ExpectWebdriverIO.StringOptions, the other with no value and commnad options
8686
export async function toHaveAttribute(
8787
received: WdioElementOrArrayMaybePromise,
8888
attribute: string,

src/matchers/element/toHaveElementProperty.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ async function condition(
3030
return { result: prop === expected, value: prop }
3131
}
3232

33-
// To review the cast to be more type safe but for now let's just no create any reqgression
33+
// To review the cast to be more type safe but for now let's keep the existing behavior to ensure no regression
3434
return compareText(prop.toString(), expected as string, options)
3535
}
3636

src/matchers/element/toHaveText.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ import { isAnyKindOfElementArray, map } from '../../util/elementsUtil.js'
1111

1212
async function singleElementCompare(el: WebdriverIO.Element, text: MaybeArray<string | RegExp | WdioAsymmetricMatcher<string>>, options: ExpectWebdriverIO.StringOptions) {
1313
const actualText = await el.getText()
14-
const checkAllValuesMatchCondition = Array.isArray(text) ?
14+
const result = Array.isArray(text) ?
1515
compareTextWithArray(actualText, text, options).result
1616
: compareText(actualText, text, options).result
1717

1818
return {
1919
value: actualText,
20-
result: checkAllValuesMatchCondition
20+
result
2121
}
2222
}
2323

src/util/executeCommand.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { awaitElements, isAnyKindOfElementArray, map } from './elementsUtil'
2020
* @param options - Optional configuration options
2121
*/
2222
export async function executeCommand<T>(
23-
nonAwaitedElements: WdioElementOrArrayMaybePromise,
23+
nonAwaitedElements: WdioElementOrArrayMaybePromise | undefined,
2424
singleElementCompareStrategy?: (awaitedElement: WebdriverIO.Element) => Promise<
2525
{ result: boolean; value?: T }
2626
>,

src/util/formatMessage.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ ${diffString}`
9595

9696
export const enhanceErrorBe = (
9797
subject: string | WebdriverIO.Element | WdioElements | undefined,
98-
_pass: boolean,
9998
context: { isNot: boolean },
10099
verb: string,
101100
expectation: string,

src/utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ async function executeCommandBe(
3737
const { isNot, expectation, verb = 'be' } = this
3838

3939
let awaitedElements: WdioElements | WebdriverIO.Element | undefined
40-
const pass = nonAwaitedElements ? await waitUntil(
40+
const pass = await waitUntil(
4141
async () => {
4242
const { elementOrArray, success, results } = await executeCommand(
4343
nonAwaitedElements,
@@ -49,9 +49,9 @@ async function executeCommandBe(
4949
},
5050
isNot,
5151
{ wait: options.wait, interval: options.interval }
52-
) : false
52+
)
5353

54-
const message = enhanceErrorBe(awaitedElements, pass, this, verb, expectation, options)
54+
const message = enhanceErrorBe(awaitedElements, this, verb, expectation, options)
5555

5656
return {
5757
pass,

test/utils.test.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,6 @@ Expected: "displayed"
273273
Received: "not displayed"`)
274274
expect(enhanceErrorBe).toHaveBeenCalledWith(
275275
received,
276-
false,
277276
expect.objectContaining({ isNot: false }),
278277
'be',
279278
'displayed',
@@ -295,7 +294,6 @@ Received: "not displayed"`)
295294
)
296295
expect(enhanceErrorBe).toHaveBeenCalledWith(
297296
received,
298-
true,
299297
expect.objectContaining({ isNot: true }),
300298
'be',
301299
'displayed',
@@ -334,7 +332,6 @@ Expected: "displayed"
334332
Received: "not displayed"`)
335333
expect(enhanceErrorBe).toHaveBeenCalledWith(
336334
[element1, element2],
337-
false,
338335
expect.objectContaining(context),
339336
context.verb,
340337
context.expectation,

0 commit comments

Comments
 (0)