Skip to content

Documentation on how to use test-utils without babel/webpack #1192

Closed
@anatolsommer

Description

@anatolsommer

What problem does this feature solve?

The documentation explains how to use vue-test-utils with different runners and build setups but not how to test a plain component without babel / webpack. Since Vue itself works great without using single file components or a build step it would be great to provide at least one simple example on how to use vue-test-utils in that case.

I have tried some obvious ways and asked for help on the forum and SO more than two weeks ago but since no one could help this really seems to be not documented at all.

https://forum.vuejs.org/t/how-to-test-plain-vue-components-not-single-file-components/58415
https://stackoverflow.com/questions/55052983/how-to-test-plain-vue-components-not-single-file-components

What does the proposed API look like?

var testUtils=require('@vue/test-utils'), Vue=require('vue');

require('jsdom-global')();    

testUtils.mount({ template: '<div>test</div>' });
// or
testUtils.mount(Vue.component('test', { template: '<div>test</div>' }));

would be obvious but fails with this error:

@vue/test-utils/dist/vue-test-utils.js:2471
var componentInstance = node.child;
TypeError: Cannot read property 'child' of undefined

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions