hasAttribute(attribute, value)
Checks if wrapper has an attribute with matching value.
Arguments
attribute
(String
): The name of the attribute.
value
(String
): The expected value of the attribute.
Returns
(Boolean
): Whether the Wrapper attribute has the expected value or not.
Example
import { mount, mountAsChild } from '@jasoeight/vue-testing';
import { expect } from 'chai';
import Example from './path/to/Example.vue';
describe('Example.vue', () => {
it('has ul with an attribute "class" with value "list" (tested with mount())', () => {
const wrapper = mount(Example);
expect(wrapper.find('ul')[0].hasAttribute('class', 'list')).to.be.true;
});
it('has ul with an attribute "class" with value "list" (tested with mountAsChild())', () => {
const wrapper = mountAsChild(Example);
expect(wrapper.find('ul')[0].hasAttribute('class', 'list')).to.be.true;
});
});