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
How to test for disabled attribute? #336
Comments
Okay - I was being silly, disabled is actually set on the select's fieldset in my component - d'oh! I have ended up with the following assertion, which still feels clunky: expect(companySelect.closest("fieldset")[0].attribs["disabled"]).toBe(""); Is there a cleaner approach? |
does |
Nah:
I also tried |
@ttrmw what does |
@ttrmw I was having a problem with |
EDITED: its working, it turns out I have to remove the quotes from "true" in the expect block and replace it with {} I'm having similar issue. I was trying to check whether my form contains a disabled button or not. The test always fails, until I remove disabled property from the button, then it works. So this fails
but this works, by removing the disabled property
So this works
|
@christiansakai that's to be expected - |
@ljharb right, thank you |
@ttrmw @christiansakai Another way you could probably check the html |
@kwnccc Unfortunately, that won't work either as For right now the cleanest and more reliable way I've found to determine if an element has the disabled attribute is the following:
This, however, can be replaced with a more accurate CSS disabled pseudo selector:
Or with a dedicated attribute lookup. For example:
|
I believe you can use wrapper.getNode().props.disabled. |
Currently you can use The bug on selector |
I think the best current way to do this is:
This will be |
@dnp1 How can we reproduce "the bug on selector |
|
This seems addressed; if you're still having trouble and using |
For me, it worked as below
Hope this helps too.... |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
For those who get here in the present, |
I also found |
This comment has been minimized.
This comment has been minimized.
expect(app.find('.btn').props().disabled).toBe(true) this seems ok !! |
This worked for me (
|
I have a component that, given some props, sets
disabled
on a select.What would be the right way to test for this? I've set up the test like so:
and, upon examining companySelect I can see that
attribs
, where I would probably expect to see the attribute, does not containdisabled
.The text was updated successfully, but these errors were encountered: