Giter Club home page Giter Club logo

Comments (4)

defnorep avatar defnorep commented on September 26, 2024 3

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 .attribute() instead of .getAttribute(), but it is more explicit what the method does when it lives alongside .hasAttribute().

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: .hasAttribute() .getAttribute() .hasProp() .getProp() .getData() .hasData()

Option 2: .hasAttribute() .getAttribute() .has() .get()

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 .getInject(), or that something is known as a data object property as opposed to a prop, for instance. Or, maybe they don't care.

It's a tough API to nail down.

from vue-test-utils.

riophae avatar riophae commented on September 26, 2024 1

Hi, @Daekano.
Though Vue forces us to make each member name unique among all props & data, it's still good to be explicit to tell what we are going to test.

from vue-test-utils.

eddyerburgh avatar eddyerburgh commented on September 26, 2024

So on reflection, getProps or get is not a good idea. It will return an unbound value, so if the prop/ method/ data/ whatever is a function that references this it won't behave as expected.

from vue-test-utils.

eddyerburgh avatar eddyerburgh commented on September 26, 2024

I'm going to close this for the moment. We should encourage users to use getAttribute on the Wrapper element:

wrapper.element.getAttribute('attribute')

And for props/data:

wrapper.vm.propName

from vue-test-utils.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.