tjw-lint / jest-serializer-vue-tjw

Jest Serializer for Vue components
MIT License
33 stars 7 forks source link

Not able to serialize Vue 3 component #81

Open kepi0809 opened 2 years ago

kepi0809 commented 2 years ago

I have the same error with this package as described here https://github.com/eddyerburgh/jest-serializer-vue/issues/49

kepi0809 commented 2 years ago

found a solution for this, needed to make .html() in the expect in every case, so only the syntactic sugar is broken. Perhaps this is worth to mention in the migration guide.

Knogobert commented 2 years ago

.element seems to work as well, giving a less prettified/minified output

mikemklee commented 1 year ago

Any updates on this?

TheJaredWilcurt commented 1 year ago

https://github.com/tjw-lint/jest-serializer-vue-tjw/pull/64

TheJaredWilcurt commented 1 year ago

Just for others to reference. This is how I'm using this library in a Vue 3 project. I've created a custom serializer for that project, then passing data into this library. Works for Jest or Vitest.

Works with defaults. Just be aware that not all features that worked on Vue 2 are available on Vue 3, you may need to do:

-expect(wrapper)
+expect(wrapper.html())
   .toMatchSnapshot();

in some places if upgrading from Vue 2 to Vue 3.

TheJaredWilcurt commented 2 weeks ago

@kepi0809 @Knogobert @mikemklee

This is a Vue 2 + Jest + CJS library. I'm almost done with a total re-write to Vue 3 + Vitest (and Jest) + ESM. If you want to test it out early: