Skip to content

Not able to serialize Vue 3 component #49

@Kaijiro

Description

@Kaijiro

Hey !

Actually the library is not able to serialize Vue 3 component, even when embed in a VueWrapper (from @vue/test-utils, right ?).

The trick I used to "extract" the template from the Vue 3 wrapper :

import {shallowMount} from "@vue/test-utils";
import MyComp from "../MyComp.vue";

describe("Vue 3 component", () => {
  it("should test with a snapshot", () => {
    const component = shallowMount(MyComp, {});

    expect(component.__app._container).toMatchSnapshot();
  });
});

By doing this trick, I actually have a readable snapshot :

// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Vue 3 component should test with a snapshot 1`] = `
<div
  data-v-app=""
>
  <div
    class="container"
  >
    <h2>
      Weeeew, this is my comp !
    </h2>
  </div>
</div>
`;

If I don't use this trick, the whole VueWrapper instance is serialized as an object, with all properties and methods.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions