Skip to content

Unit test example needs a dom element #931

Closed
@Cortrah

Description

@Cortrah

Hi Folk,

The unit test example here doesn't work out of the box with either the browserify or webpack templates.
https://vuejs.org/v2/guide/unit-testing.html#Writing-Testable-Components

The container needs to be passed in with the propsData or they are not used
function getRenderedText (Component, propsData) {
const container = document.createElement('div');
const Ctor = Vue.extend(Component);
const vm = new Ctor({
el: container,
propsData: propsData
});
return vm.$el.textContent
}

if you want a repository to look at it easily it is here

Thanks for all you are doing. It's making being a js developer more pleasant than it was by far.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions