getAttributeValue(attribute)

Returns the value of an attribute of the element.

Arguments

attribute (String): The name of the attribute.

Returns

(String|null): The value of the attribute or null.

Example

Example Component

import { mount, mountAsChild } from '@jasoeight/vue-testing';
import { expect } from 'chai';
import Example from './path/to/Example.vue';

describe('Example.vue', () => {
    it('has fullname element with an attribute "style" (tested with mount())', () => {
        const wrapper = mount(Example);
        expect(wrapper.find('h1')[0].getAttributeValue('style')).to.equal('color: red;');
    });

    it('has fullname element with an attribute "style" (tested with mountAsChild())', () => {
        const wrapper = mountAsChild(Example);
        expect(wrapper.find('h1')[0].getAttributeValue('style')).to.equal('color: red;');
    });
});

results matching ""

    No results matching ""