@@ -27,6 +27,7 @@ async function conditionAttrAndValue(el: WebdriverIO.Element, attribute: string,
2727}
2828
2929export async function toHaveAttributeAndValue ( received : WdioElementMaybePromise , attribute : string , value : string | RegExp | WdioAsymmetricMatcher < string > , options : ExpectWebdriverIO . StringOptions = DEFAULT_OPTIONS ) {
30+ const isNot = this . isNot
3031 const { expectation = 'attribute' , verb = 'have' } = this
3132
3233 let el = await received ?. getElement ( )
@@ -37,7 +38,7 @@ export async function toHaveAttributeAndValue(received: WdioElementMaybePromise,
3738 attr = result . values
3839
3940 return result . success
40- } , options )
41+ } , isNot , options )
4142
4243 const expected = wrapExpectedWithArray ( el , attr , value )
4344 const message = enhanceError ( el , expected , attr , this , verb , expectation , attribute , options )
@@ -48,8 +49,9 @@ export async function toHaveAttributeAndValue(received: WdioElementMaybePromise,
4849 } as ExpectWebdriverIO . AssertionResult
4950}
5051
51- async function toHaveAttributeFn ( received : WdioElementMaybePromise , attribute : string , options : ExpectWebdriverIO . StringOptions ) {
52- const { expectation = 'attribute' , verb = 'have' , isNot } = this
52+ async function toHaveAttributeFn ( received : WdioElementMaybePromise , attribute : string ) {
53+ const isNot = this . isNot
54+ const { expectation = 'attribute' , verb = 'have' } = this
5355
5456 let el = await received ?. getElement ( )
5557
@@ -58,9 +60,9 @@ async function toHaveAttributeFn(received: WdioElementMaybePromise, attribute: s
5860 el = result . el as WebdriverIO . Element
5961
6062 return result . success
61- } , options )
63+ } , isNot , { } )
6264
63- const message = enhanceError ( el , ! isNot , pass , this , verb , expectation , attribute , options )
65+ const message = enhanceError ( el , ! isNot , pass , this , verb , expectation , attribute , { } )
6466
6567 return {
6668 pass,
@@ -84,7 +86,7 @@ export async function toHaveAttribute(
8486 // Name and value is passed in e.g. el.toHaveAttribute('attr', 'value', (opts))
8587 ? await toHaveAttributeAndValue . call ( this , received , attribute , value , options )
8688 // Only name is passed in e.g. el.toHaveAttribute('attr')
87- : await toHaveAttributeFn . call ( this , received , attribute , options )
89+ : await toHaveAttributeFn . call ( this , received , attribute )
8890
8991 await options . afterAssertion ?.( {
9092 matcherName : 'toHaveAttribute' ,
0 commit comments