-
Notifications
You must be signed in to change notification settings - Fork 668
Add a getProp and getAttribute methods #27
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
Comments
Happened across this issue since you are asking for input on it, so here's my input: This API makes sense to me. At first I wondered why we don't just use Where things start to get dicey (in my opinion) is when we stop looking at attributes and start looking at Vue instance properties such as props, data object properties, computed properties, methods, injected dependencies, etc. All of these things are accessed homogeneously and it's up to the developer to have an understanding of what each one is. What that means to your proposed API is that we have to start considering if props are different from those other Vue instance properties. Do we create methods for each type? Or do we embrace Vue's harmonized instance member access somehow with a differently named API? Attributes are sufficiently different from props to warrant different treatment. Option 1: Option 2: Maybe the type or location of the instance member is worth testing. Someone might want to ensure that a provided service is available on a descendant component using It's a tough API to nail down. |
Hi, @Daekano. |
So on reflection, |
I'm going to close this for the moment. We should encourage users to use wrapper.element.getAttribute('attribute') And for props/data: wrapper.vm.propName |
Currently we have a hasAttribute, hasProp and hasStyle methods. These aren't great for assertions, as they return booleans. If tests fail, they will fail because they were expecting true but received false.
For example, when asserting attributes with
hasAttribute
:An alternative would be to have a
getAttribute
function:This makes debugging a lot easier, and provides a better testing experience.
I think we should add get methods for props and attributes. We could do the same with style, but this won't be ideal - because the styles we return will be the computed styles:
I think we should keep
hasAttribute
,hasProp
andhasStyle
, but addgetAttribute
andgetProp
The text was updated successfully, but these errors were encountered: