eddyerburgh / jest-serializer-vue

Jest Serializer for Vue components
MIT License
62 stars 22 forks source link

fix: add compatibility with @vue/test-utils@2 and vue3 #56

Closed renatodeleao closed 1 year ago

renatodeleao commented 1 year ago

As described on https://github.com/eddyerburgh/jest-serializer-vue/issues/49#issuecomment-1316950926, closes https://github.com/eddyerburgh/jest-serializer-vue/issues/49

It doesn't work currently, because isVueInstance property was already deprecated in @vue/test-utils@1 and as such it does not exist in v2 which is mandatory for vue3 app. That property is used to assert if the input is a @vue/test-utils wrapper. The fix was to replace it with html function check, since we actually call it a few lines bellow.

 const isVueWrapper = received => ( 
   received && 
   typeof received === 'object' && 
-   typeof received.isVueInstance === 'function' 
+   typeof received.html === 'function' 

https://github.com/eddyerburgh/jest-serializer-vue/blob/600b2c0e68e4a15c113d22beb10d706947e7409a/index.js#L4-L7

Notes

eddyerburgh commented 1 year ago

This repo was in a dirty state with an unpublished breaking change, so I've released this fix in a new major version—v3.0.0 (v3.1.0 is equivalent, whoops).

renatodeleao commented 1 year ago

@eddyerburgh thank you sir!