diff --git a/packages/create-instance/create-instance.js b/packages/create-instance/create-instance.js
index f5a7e8321..c898222f3 100644
--- a/packages/create-instance/create-instance.js
+++ b/packages/create-instance/create-instance.js
@@ -1,7 +1,6 @@
// @flow
import Vue from 'vue'
-import cloneDeep from 'lodash/cloneDeep'
import { addSlots } from './add-slots'
import { addScopedSlots } from './add-scoped-slots'
import addMocks from './add-mocks'
@@ -93,19 +92,6 @@ export default function createInstance (
addAttrs(vm, options.attrs)
addListeners(vm, options.listeners)
- vm.$_vueTestUtils_mountingOptionsSlots = options.slots
- vm.$_vueTestUtils_originalSlots = cloneDeep(vm.$slots)
- vm.$_vueTestUtils_originalUpdate = vm._update
- vm._update = function (vnode, hydrating) {
- // updating slot
- if (this.$_vueTestUtils_mountingOptionsSlots) {
- this.$slots = cloneDeep(this.$_vueTestUtils_originalSlots)
- addSlots(this, this.$_vueTestUtils_mountingOptionsSlots)
- vnode = this._render()
- }
- this.$_vueTestUtils_originalUpdate(vnode, hydrating)
- }
-
if (options.scopedSlots) {
if (window.navigator.userAgent.match(/PhantomJS/i)) {
throwError('the scopedSlots option does not support PhantomJS. Please use Puppeteer, or pass a component.')
diff --git a/packages/test-utils/src/set-watchers-to-sync.js b/packages/test-utils/src/set-watchers-to-sync.js
index 93fd85d7a..e6cdf0161 100644
--- a/packages/test-utils/src/set-watchers-to-sync.js
+++ b/packages/test-utils/src/set-watchers-to-sync.js
@@ -1,3 +1,5 @@
+import { VUE_VERSION } from './consts'
+
function setDepsSync (dep) {
dep.subs.forEach(setWatcherSync)
}
@@ -24,4 +26,16 @@ export function setWatchersToSync (vm) {
setWatcherSync(vm._watcher)
vm.$children.forEach(setWatchersToSync)
+ // preventing double registration
+ if (!vm.$_vueTestUtils_updateInSetWatcherSync) {
+ vm.$_vueTestUtils_updateInSetWatcherSync = vm._update
+ vm._update = function (vnode, hydrating) {
+ this.$_vueTestUtils_updateInSetWatcherSync(vnode, hydrating)
+ if (VUE_VERSION >= 2.1 && this._isMounted && this.$options.updated) {
+ this.$options.updated.forEach((handler) => {
+ handler.call(this)
+ })
+ }
+ }
+ }
}
diff --git a/test/specs/mounting-options/slots.spec.js b/test/specs/mounting-options/slots.spec.js
index aa1b0f7bf..d4a779c05 100644
--- a/test/specs/mounting-options/slots.spec.js
+++ b/test/specs/mounting-options/slots.spec.js
@@ -113,7 +113,6 @@ describeWithMountingMethods('options.slots', (mountingMethod) => {
const wrapper5 = mountingMethod(ComponentWithSlots, { slots: { default: '1{{ foo }}2' }})
expect(wrapper5.find('main').html()).to.equal('
1
2
' }}) expect(wrapper6.find('main').html()).to.equal('1
2
2
3' }}) diff --git a/test/specs/mounting-options/sync.spec.js b/test/specs/mounting-options/sync.spec.js index 7651f28cb..2268c4e0b 100644 --- a/test/specs/mounting-options/sync.spec.js +++ b/test/specs/mounting-options/sync.spec.js @@ -1,3 +1,4 @@ +import sinon from 'sinon' import { describeWithShallowAndMount } from '~resources/utils' describeWithShallowAndMount('options.sync', (mountingMethod) => { @@ -110,4 +111,38 @@ describeWithShallowAndMount('options.sync', (mountingMethod) => { done() }) }) + + it('call updated when sync is not false', () => { + const childComponentSpy = sinon.stub() + const ChildComponent = { + template: '