Skip to content

Commit d2d4421

Browse files
committed
fix: allow plugins to be re-installed in localVue instance
close vuejs#406
1 parent 91472e4 commit d2d4421

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/create-local-vue.js

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ function createLocalVue (): Component {
3232
instance.options._base = instance
3333

3434
// compat for vue-router < 2.7.1 where it does not allow multiple installs
35+
instance._installedPlugins = []
3536
const use = instance.use
3637
instance.use = (plugin, ...rest) => {
3738
if (plugin.installed === true) {

test/specs/create-local-vue.spec.js

+8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { createLocalVue } from '~vue-test-utils'
2+
import Vue from 'vue'
23
import Vuex from 'vuex'
34
import Vuetify from 'vuetify'
45
import VueRouter from 'vue-router'
@@ -97,6 +98,13 @@ describe('createLocalVue', () => {
9798
expect(typeof freshWrapper.vm.$route).to.equal('undefined')
9899
})
99100

101+
it('installs Router regardless of global Vue', () => {
102+
Vue.use(VueRouter)
103+
const localVue = createLocalVue()
104+
localVue.use(VueRouter)
105+
expect(VueRouter.install.installed).to.equal(true)
106+
})
107+
100108
it('use can take additional arguments', () => {
101109
const localVue = createLocalVue()
102110
const pluginOptions = { foo: 'bar' }

0 commit comments

Comments
 (0)