Jest Serializer for Vue Snapshots

4.0.0 · deprecated · verified Tue Apr 21

jest-serializer-vue-tjw is a Jest snapshot serializer specifically designed to make Vue component snapshots more readable and maintainable by normalizing HTML output. It handles common issues like attribute ordering, inline functions, and various `data-` attributes that can cause unnecessary snapshot churn. The package is currently at version 4.0.0, but this version primarily serves as a deprecation notice. The library is no longer actively maintained and has been replaced by `vue3-snapshot-serializer`. While `jest-serializer-vue-tjw` supported both Vue 2 and Vue 3 (with some caveats for the latter), its replacement is Vue 3-only and introduces several new features and improved configuration options. Users are advised to migrate to `vue3-snapshot-serializer` for new projects or Vue 3 codebases, or to pin this library to `3.x.x` if they must remain on Vue 2.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates the `jest.config.js` setup for integrating the serializer and example configuration settings within `package.json` for customized snapshot behavior.

{
  "jest": {
    "snapshotSerializers": [
      "<rootDir>/node_modules/jest-serializer-vue-tjw"
    ]
  },
  "jest-serializer-vue-tjw": {
    "removeDataTest": true,
    "sortAttributes": true,
    "clearInlineFunctions": true,
    "attributesToClear": ["data-random", "id"]
  }
}

view raw JSON →