Skip to content

using shallowMount on a component that uses Symbol causes tests to crash #1076

Closed
@liamdebeasi

Description

@liamdebeasi

When using shallowMount on a component that uses Symbol as a value for a property, Vue Test Utils fail to run. I receive the following error:

 TypeError: Failed to execute 'setAttribute' on 'Element': parameter 2 is a symbol, which cannot be converted to a string.

      at Object.exports.DOMString (node_modules/webidl-conversions/lib/index.js:228:15)
      at patchAttr (node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.js:207:16)
      at patchProp (node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.js:406:9)
      at mountElement (node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:3751:25)
      at processElement (node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:3724:13)
      at patch (node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:3644:21)
      at ReactiveEffect.componentUpdateFn [as fn] (node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:4181:21)
      at ReactiveEffect.run (node_modules/@vue/reactivity/dist/reactivity.cjs.js:164:29)
      at setupRenderEffect (node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:4300:9)

I would expect there to be no error when using shallowMount. When using mount, the tests run as expected.


Steps to reproduce:

  1. Clone https://github.com/liamdebeasi/vue-test-utils-symbol.
  2. Run npm install.
  3. Run npm run test:unit. Observe that the tests fail on the error above.
  4. Open src/MyCmp.vue and change the default value for myProp from Symbol() to '123'.
  5. Run npm run test:unit. Observe that the tests pass as expected.

This is a blocker for some Vue users upgrading to Ionic 6, so it would be great if this could get fixed: ionic-team/ionic-framework#24181. We make use of Symbols to account for this change in behavior with Vue 3.1: vuejs/core#3889

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions