Skip to content

Missing custom attributes in Vuetify element when shallowMount #884

@trollepierre

Description

@trollepierre
Contributor

Version

1.0.0-beta.22

Reproduction link

https://codesandbox.io/s/9z5oy2kn3y

Steps to reproduce

When I set some custom attributes in , I cannot see them in the generated snapshot

<template>
  <v-icon
      :style="{color: iconColor}"
      class="icon">
      {{ icon }}
    </v-icon>
</template>

<script>
export default {
  name: "TestComponent",
  props: {
      iconColor: { type: String, default: undefined },
    },
};
</script>

What is expected?

<v-icon-stub
  class="icon"
  style="color: yellow;"
>
cancel
</v-icon-stub>

What is actually happening?

<v-icon-stub
  fakeprops="fakeProps"
>
cancel
</v-icon-stub>

I noticed the fake-props are passing inside the snapshot. I think this is weird also

Activity

eddyerburgh

eddyerburgh commented on Aug 4, 2018

@eddyerburgh
Member

The issue here is the style attribute.

The functional component receives a raw data object, where static style values are converted to an object.

One imperfect solution I found is to stringify the object and replace double quotation marks with back ticks, but it's not great:

<v-icon-stub
  class="icon"
  style="`color`: `yellow`";
>
trollepierre

trollepierre commented on Aug 4, 2018

@trollepierre
ContributorAuthor

that would be better (as a first step) ^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @trollepierre@eddyerburgh

        Issue actions

          Missing custom attributes in Vuetify element when shallowMount · Issue #884 · vuejs/vue-test-utils