text()

Set the text of the element.

Returns

(String): The text of the element.

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('renders the correct fullname (tested with mount())', () => {
        const wrapper = mount(Example, {
            propsData: {
                firstname: 'John',
                lastname: 'Doe'
            }
        });
        expect(wrapper.find('h1')[0].text()).to.equal('John Doe');
    });

    it('renders the correct fullname (tested with mountAsChild())', () => {
        const wrapper = mountAsChild(Example, {
            props: {
                firstname: 'John',
                lastname: 'Doe'
            }
        });
        expect(wrapper.find('h1')[0].text()).to.equal('John Doe');
    });
});

results matching ""

    No results matching ""