11// @flow
2-
3- import Vue from 'vue'
42import pretty from 'pretty'
53import getSelector from './get-selector'
64import { REF_SELECTOR , FUNCTIONAL_OPTIONS , VUE_VERSION } from 'shared/consts'
7- import config from './config'
85import WrapperArray from './wrapper-array'
96import ErrorWrapper from './error-wrapper'
107import { throwError , getCheckedEvent , isPhantomJS } from 'shared/util'
@@ -455,8 +452,6 @@ export default class Wrapper implements BaseWrapper {
455452 * Sets vm props
456453 */
457454 setProps ( data : Object ) : void {
458- const originalConfig = Vue . config . silent
459- Vue . config . silent = config . silent
460455 if ( this . isFunctionalComponent ) {
461456 throwError (
462457 `wrapper.setProps() cannot be called on a functional component`
@@ -480,38 +475,26 @@ export default class Wrapper implements BaseWrapper {
480475 )
481476 }
482477 if (
483- ! this . vm ||
484- ! this . vm . $options . _propKeys ||
485- ! this . vm . $options . _propKeys . some ( prop => prop === key )
478+ VUE_VERSION <= 2.3 &&
479+ // $FlowIgnore : Problem with possibly null this.vm
480+ ( ! this . vm . $options . _propKeys ||
481+ ! this . vm . $options . _propKeys . some ( prop => prop === key ) )
486482 ) {
487- if ( VUE_VERSION > 2.3 ) {
488- // $FlowIgnore : Problem with possibly null this.vm
489- this . vm . $attrs [ key ] = data [ key ]
490- return
491- }
492483 throwError (
493484 `wrapper.setProps() called with ${ key } property which ` +
494485 `is not defined on the component`
495486 )
496487 }
497488
498- if ( this . vm && this . vm . _props ) {
499- // Set actual props value
500- this . vm . _props [ key ] = data [ key ]
501- // $FlowIgnore : Problem with possibly null this.vm
502- this . vm [ key ] = data [ key ]
503- } else {
504- // $FlowIgnore : Problem with possibly null this.vm.$options
505- this . vm . $options . propsData [ key ] = data [ key ]
506- // $FlowIgnore : Problem with possibly null this.vm
507- this . vm [ key ] = data [ key ]
508- // $FlowIgnore : Need to call this twice to fix watcher bug in 2.0.x
509- this . vm [ key ] = data [ key ]
489+ if ( this . vm && this . vm . $parent ) {
490+ this . vm . $parent . vueTestUtils_childProps [ key ] = data [ key ]
510491 }
511492 } )
512493 // $FlowIgnore : Problem with possibly null this.vm
513494 this . vm . $forceUpdate ( )
514- Vue . config . silent = originalConfig
495+ // We need to explicitly trigger parent watcher to support sync scenarios
496+ // $FlowIgnore : Problem with possibly null this.vm
497+ this . vm . $parent . _watcher . run ( )
515498 }
516499
517500 /**
0 commit comments