setText(text)

Set the text of the element.

Arguments

text (String): The text for the element.

Example

Example Component

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

describe('Example.vue', () => {
    it('sets a new text to the fullname element (tested with mount())', () => {
        const wrapper = mount(Example);
        const fullnameElement = wrapper.find('h1')[0];
        expect(fullnameElement.text()).to.equal(' ');
        fullnameElement.setText('New Text');
        expect(fullnameElement.text()).to.equal('New Text');
    });

    it('sets a new text to the fullname element (tested with mountAsChild())', () => {
        const wrapper = mountAsChild(Example);
        const fullnameElement = wrapper.find('h1')[0];
        expect(fullnameElement.text()).to.equal(' ');
        fullnameElement.setText('New Text');
        expect(fullnameElement.text()).to.equal('New Text');
    });
});

results matching ""

    No results matching ""