Skip to content

Port custom snapshot serializer for Vue from gitlab-ui

jest-serializer-vue was not updated for two years and does not meet all required functionality

Neither does more recent https://www.npmjs.com/package/jest-serializer-vue-tjw - unfortunately it is missing functionality of dropping certain HTML attributes (and Vue3-based @vue/test-utils will render slot-scope attribute on tags)

Also jest-serializer-vue-tjw relies on cheerio for parsing HTML which is heavy. Instead we're implementing our own serializer, which does three things:

  • drops HTML comments (Vue3 renders them)
  • drops values for specific attributes (Vue2 vs Vue3 handling of "booleanish" attributes like disabled / readonly`)
  • drops specific HTML attributes (for now this is just slot-scope)

This allows us to verify that snapshots for vue2 and vue3 are literally the same


Original work on serializer was done in gitlab-ui!3091 (merged)

We need to verify that code in serializer is able to serialize our snapshots identically for Vue2 and Vue3 run (which could be performed on xanf-vue branch with VUE_VERSION=3 env variable

Theoretically it should not be the problem, however we might discover additional differences, which might require additional effort

Edited by Illya Klymov