Skip to content

Releases: tjw-lint/jest-serializer-vue-tjw

Replace [object Object] with data and Remove data-v-id's

16 Jan 05:46
c00bcc5
Compare
Choose a tag to compare

Breaking changes to API

  • None

Breaking Changes to snapshots

  • If you are using any 3rd-party components with scoped styles, and your mount based snapshots include them, then those tests will break. Specifically it will remove their scoping attributes (data-v-1234abcd=""). This was done so that your future snapshots won't break when updating that dependency and it's ID's all change.

data-v-id

  • If your HTML attributes contained any JSON data, previously they would display as href="[object Object]". Now they will display the actual data, like href="{ key: 'value' }".

replace object Object

These changes mean your tests will now fail, until you update the snapshots to this new formatting.

Recommended: Update to this version in your codebase in its own branch/PR. Run your test command with -- -u at the end. Such as npm run unit -- -u. This should auto-update your snapshots.

Alternative: If you prefer the previous formatting you can use these settings to keep everything as is:

vue.config.js

module.exports = {
  pluginOptions: {
    jestSerializer: {
      // Set this to false if you want your snapshots to retain the data-v-token="" attributes
      removeDataVId: true,
      // Set this to false if you don't want to see JSON attribute data in snapshots
      stringifyObjects: true
  }
};

New Features

  • You can now enable/disable removing data-v-1234abcd attributes
  • You can now enable/disable displaying JSON data in HTML attributes

Bug fixes

  • None

Maintenance

  • Created a .gitignore so now this dependency will include the bare minimum number of files during install
  • All dependencies have been updated
  • Updated the documentation
  • Added some shields/badges to the README
  • Created new tests for the new features
  • Increased devDeps by 1 to test 3rd party libraries with scoped styles
  • Pull request template created
  • Added a test debugger npm script

Code Changes:

Formatting options, API, and test token removal

12 Jan 23:06
dae4792
Compare
Choose a tag to compare

Breaking Changes

  • If you are using data-test attributes, they will be removed from your snapshots now.
  • Your snapshots will be much better formatted now.

Example of improved formatting compared to previous release:

Difference in formatting

These changes mean your tests will now fail, until you update the snapshots to this new formatting.

Recommended: Update to this version in your codebase in its own branch/PR. Run your test command with -- -u at the end. Such as npm run unit -- -u. This should auto-update your snapshots.

Alternative: If you prefer the previous formatting you can use these settings to keep everything as is:

vue.config.js

module.exports = {
  pluginOptions: {
    jestSerializer: {
      // Set this to false if you want your snapshots to retain the data-test="token" attributes
      removeDataTest: true,
      // Setting this to true will use pretty's defaults, the same that were used in the last release
      pretty: true
  }
};

New Features

  • Vue config compatible API introduced
  • You can now enable/disable removing data-server-rendered and data-test attributes
  • Much better default formatting
  • Full control over formatting via new pretty options API

Bug fixes

  • We now remove all instance of data-server-rendered="true" not just the first instance

Maintenance

  • New maintainer
  • All dependencies have been updated
  • Switched to Travis for automated linting/testing for all PR's
  • Added an editorconfig
  • Changelog now handled in GitHub releases
  • Adopted "No Ideologies" Code of Conduct
  • Added JSDoc blocks above all functions
  • package-lock.json commited. Cut the cord on yarn.
  • Lowered devDeps by 5

Code Changes: