-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
feat(matchers): add expect(locator).toContainClass() #14219
Conversation
44cd222
to
04e2b47
Compare
a731e09
to
be98ef4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very nice, requires some polishing in the docs (examples of the other languages) then it should be good to go!
Co-authored-by: Max Schmitt <max@schmitt.mx>
Co-authored-by: Max Schmitt <max@schmitt.mx>
Co-authored-by: Max Schmitt <max@schmitt.mx>
Co-authored-by: Max Schmitt <max@schmitt.mx>
Co-authored-by: Max Schmitt <max@schmitt.mx>
Co-authored-by: Max Schmitt <max@schmitt.mx>
@mxschmitt looks like I fixed everything you comment. What next? |
await expect(itemLocator).toContainClass(['alice', 'bob', 'carl']); // fail, length mismatch | ||
``` | ||
|
||
```java |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All languages should have equivalent examples. You can make JS snippet smaller or other languages bigger.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just copypasted docs for toHaveClass and renamed it :)
@@ -1297,9 +1297,9 @@ export class Frame extends SdkObject { | |||
omitAttached = true; | |||
else if (options.isNot && options.expression === 'to.have.count' && options.expectedNumber !== 0) | |||
omitAttached = true; | |||
else if (!options.isNot && options.expression.endsWith('.array') && options.expectedText!.length === 0) | |||
else if (!options.isNot && options.expression.endsWith('.array') && options.expectedText?.length === 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because expectedText could be undefined, and it is in my case.
omitAttached = true; | ||
else if (options.isNot && options.expression.endsWith('.array') && options.expectedText!.length > 0) | ||
else if (options.isNot && options.expression.endsWith('.array') && (options.expectedText?.length || 0) > 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did this change?
if (expression === 'to.contain.class.array') { | ||
const receivedClassNames = elements.map(e => e.className); | ||
|
||
if (!Array.isArray(options.expectedValue) || options.expectedValue.length !== elements.length) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not match the logic of to.contain.text.array
, toContainClass relative to toHaveClass should be the same as toContainText relative to toHaveText, let's make sure they are consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please give me a testcase for what you are saying? This condition just ensures that elements and values length are equal.
Co-authored-by: Pavel Feldman <pavel.feldman@gmail.com>
Co-authored-by: Pavel Feldman <pavel.feldman@gmail.com>
Co-authored-by: Pavel Feldman <pavel.feldman@gmail.com>
Co-authored-by: Pavel Feldman <pavel.feldman@gmail.com>
So, guys, I think this mr on your side now) I'll continue to watch for #14117 |
#14117