Vue-test-utils: Mounting Option `stubs` not working.

Created on 14 Jun 2018  ·  7Comments  ·  Source: vuejs/vue-test-utils

Version

1.0.0-beta.18

Reproduction link

https://jsfiddle.net/cpxPratik/sa3yqznw/3/

Steps to reproduce

When shallowmounting or mounting, giving stubs mounting option such as stubs: ['router-link'].

What is expected?

Should not have any warning.

What is actually happening?

Warning on console: [Vue warn]: Unknown custom element: <router-link-stub> - did you register the component correctly? For recursive components, make sure to provide the "name" option.


Doing VueTestUtils.config.stubs['router-link'] = '<div />' solves it, but mounting option should have worked too unless i am misunderstanding sth. Warning was produced after updating from 1.0.0-beta.14 to 1.0.0-beta.16, there was not warning beforehand.

bug

Most helpful comment

I still experience the same behaviour in beta.19.

All 7 comments

Thanks for the bug report.

A temporary fix is to add it to the ignored elements:

import Vue from 'vue'

Vue.config.ignoredElements.push('router-link-stub')

Could the mocks option be affected as well? Just tried to upgrade from beta.17 to beta.18 and I am seeing some strange test failures.

That's a seperate issue that's been fixed in #709. I'll release this evening 👍

I still experience the same behaviour in beta.19.

Can you create an issue with a reproduction?

@eddyerburgh @cars10

The following codes BEFORE tests fixed the behavior in my environment with beta.20.

import Vue from 'vue';

Vue.config.ignoreElements = [];

It seems Vue.config.ignoreElements must be assigned prior to the test?
https://github.com/vuejs/vue-test-utils/pull/714/files#diff-814c51828b90615b0a6800b1ecd862ecR67

Can you check if setting it in mount.js fixes the issue?

Was this page helpful?
0 / 5 - 0 ratings