@@ -16,7 +16,6 @@ import { componentNeedsCompiling, isPlainObject } from 'shared/validators'
1616import { validateSlots } from './validate-slots'
1717import createScopedSlots from './create-scoped-slots'
1818import { extendExtendedComponents } from './extend-extended-components'
19- import Vue from 'vue'
2019
2120function vueExtendUnsupportedOption ( option : string ) {
2221 return `options.${ option } is not supported for ` +
@@ -36,15 +35,12 @@ const UNSUPPORTED_VERSION_OPTIONS = [
3635
3736export default function createInstance (
3837 component : Component ,
39- options : Options
38+ options : Options ,
39+ _Vue : Component
4040) : Component {
4141 // Remove cached constructor
4242 delete component . _Ctor
4343
44- const _Vue = options . localVue
45- ? options . localVue . extend ( )
46- : Vue . extend ( )
47-
4844 // make sure all extends are based on this instance
4945 _Vue . options . _base = _Vue
5046
@@ -75,7 +71,8 @@ export default function createInstance (
7571 component = createFunctionalComponent ( component , options )
7672 } else if ( options . context ) {
7773 throwError (
78- `mount.context can only be used when mounting a ` + `functional component`
74+ `mount.context can only be used when mounting a ` +
75+ `functional component`
7976 )
8077 }
8178
@@ -84,13 +81,15 @@ export default function createInstance (
8481 }
8582
8683 // Replace globally registered components with components extended
87- // from localVue. This makes sure the beforeMount mixins to add stubs
88- // is applied to globally registered components.
84+ // from localVue.
8985 // Vue version must be 2.3 or greater, because of a bug resolving
9086 // extended constructor options (https://github.com/vuejs/vue/issues/4976)
9187 if ( vueVersion > 2.2 ) {
9288 for ( const c in _Vue . options . components ) {
9389 if ( ! isRequiredComponent ( c ) ) {
90+ const extendedComponent = _Vue . extend ( _Vue . options . components [ c ] )
91+ extendedComponent . options . $_vueTestUtils_original =
92+ _Vue . options . components [ c ]
9493 _Vue . component ( c , _Vue . extend ( _Vue . options . components [ c ] ) )
9594 }
9695 }
0 commit comments