Skip to content

setValue triggering "ReferenceError: $set is not defined" #1253

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wspringer opened this issue Jun 6, 2019 · 1 comment
Closed

setValue triggering "ReferenceError: $set is not defined" #1253

wspringer opened this issue Jun 6, 2019 · 1 comment

Comments

@wspringer
Copy link

Version

1.0.0-beta.29

Reproduction link

https://circleci.com/gh/wspringer/vue-autoextra/4

Steps to reproduce

Note that even though the test claim to be succesful, they are not.

My component is using scoped slots. If I'm setting a value on an input that has an associated model, then the first bit of setValue — setting the element's value — is okay, but when the 'input' trigger is fired, it produces this error:

console.error node_modules/vue/dist/vue.runtime.common.dev.js:621
    [Vue warn]: Error in v-on handler: "ReferenceError: $set is not defined"

    (found in <Root>)

  console.error node_modules/vue/dist/vue.runtime.common.dev.js:1884
    ReferenceError: $set is not defined
        at input (eval at createFunction (/Users/wilfred/workspace/vue-autoextra/node_modules/vue-template-compiler/build.js:4623:12), <anonymous>:3:288)
        at invokeWithErrorHandling (/Users/wilfred/workspace/vue-autoextra/node_modules/vue/dist/vue.runtime.common.dev.js:1850:26)
        at HTMLInputElement.invoker (/Users/wilfred/workspace/vue-autoextra/node_modules/vue/dist/vue.runtime.common.dev.js:2175:14)
        at HTMLInputElement.original._wrapper (/Users/wilfred/workspace/vue-autoextra/node_modules/vue/dist/vue.runtime.common.dev.js:6889:25)
        at invokeEventListeners (/Users/wilfred/workspace/vue-autoextra/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:193:27)
        at HTMLInputElementImpl._dispatch (/Users/wilfred/workspace/vue-autoextra/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:119:9)
        at HTMLInputElementImpl.dispatchEvent (/Users/wilfred/workspace/vue-autoextra/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:82:17)
        at HTMLInputElementImpl.dispatchEvent (/Users/wilfred/workspace/vue-autoextra/node_modules/jsdom/lib/jsdom/living/nodes/HTMLElement-impl.js:30:27)
        at HTMLInputElement.dispatchEvent (/Users/wilfred/workspace/vue-autoextra/node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js:157:21)
        at Wrapper.trigger (/Users/wilfred/workspace/vue-autoextra/node_modules/@vue/test-utils/dist/vue-test-utils.js:3759:16)
        at Wrapper.setValue (/Users/wilfred/workspace/vue-autoextra/node_modules/@vue/test-utils/dist/vue-test-utils.js:3722:10)
        at VueComponent.<anonymous> (/Users/wilfred/workspace/vue-autoextra/src/component.test.js:38:18)
        at Array.<anonymous> (/Users/wilfred/workspace/vue-autoextra/node_modules/vue/dist/vue.runtime.common.dev.js:1976:12)
        at flushCallbacks (/Users/wilfred/workspace/vue-autoextra/node_modules/vue/dist/vue.runtime.common.dev.js:1902:14)
        at process._tickCallback (internal/process/next_tick.js:68:7)

What is expected?

I'm expecting to be able to call setValue without a problem.

What is actually happening?

The trigger is not firing, causing the model to not be updated.


The test is here: https://github.com/wspringer/vue-autoextra/blob/master/src/component.test.js
The component getting tested is here: https://github.com/wspringer/vue-autoextra/blob/master/src/component.js
The expected behavior is demonstrated here: https://medium.com/east-pole/from-angular-to-vue-fb22c7ffab21

@wspringer
Copy link
Author

wspringer commented Jun 6, 2019

Okay, this more self-contained test also fails with the same error about $set not being defined.

  it('should be okay using a slot', () => {
    const SlotComponent = {
      props: ['person'],
      template: `
      <em><slot :person="person"/></em>
      `.trim()
    }    
    const person = { name: 'Wilfred' }
    const wrapped = mount(SlotComponent, {
      scopedSlots: {
        default: '<input type="text" v-model="props.person.name"/>'
      },
      propsData: {
        "person": person
      }
    })
    expect(wrapped.findAll('input').length).toEqual(1)
    const control = wrapped.findAll('input').at(0)
    control.setValue('Charles')
    expect(person.name).toEqual('Charles')
  })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant