We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
1.0.0-beta.24
https://github.com/kb-coder/vue-test-utils-bug
The two tests in HelloWorld.spec.js will fail.
Both tests should succeed. According to the docs (https://vue-test-utils.vuejs.org/api/wrapper/#attributes-key), I should be able to check the attribute using this syntax:
expect(element.attributes('for'), 'label for attribute').to.equal('myInput')
For example:
it('label for attribute should be "myInput"', mochaAsync(async () => { const msg = 'new message' const wrapper = await shallowMount(HelloWorld, { attachToDocument: true, propsData: { msg } }) const element = wrapper.find('label') expect(element.attributes('for'), 'label for attribute').to.equal('myInput') // fails }))
The element.attributes('for') returns the entire element object and not the value of the 'for' attribute.
However, the following line does work:
expect(element.attributes().for, 'label for attribute').to.equal('myInput')
According to the documentation, both ways of getting to the attribute should work.
Console shows:
element.attributes('for') {data-v-.....: "", for: "myInput" .....}
elements.attributes().for "myInput"
The text was updated successfully, but these errors were encountered:
I tried this on both an input using the "type" attribute and a label using the "for" attribute. Both are included in the repro.
Sorry, something went wrong.
attributes([key]) is added at #941. It is 2 days ago. This is not included in 1.0.0-beta.24. https://github.com/vuejs/vue-test-utils/releases/tag/v1.0.0-beta.24
attributes([key])
The latest version is released now, so this feature will be working as intended
No branches or pull requests
Version
1.0.0-beta.24
Reproduction link
https://github.com/kb-coder/vue-test-utils-bug
Steps to reproduce
The two tests in HelloWorld.spec.js will fail.
What is expected?
Both tests should succeed. According to the docs (https://vue-test-utils.vuejs.org/api/wrapper/#attributes-key), I should be able to check the attribute using this syntax:
expect(element.attributes('for'), 'label for attribute').to.equal('myInput')
For example:
What is actually happening?
The element.attributes('for') returns the entire element object and not the value of the 'for' attribute.
However, the following line does work:
According to the documentation, both ways of getting to the attribute should work.
Console shows:
The text was updated successfully, but these errors were encountered: