Skip to content

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

Improved arrow function detection in snapshots

06 Jun 03:18
013b3c1
Compare
Choose a tag to compare

Breaking changes to API

  • None

Breaking changes to snapshots

  • Some snapshots may change around inline functions.
  • If you updated Vue and your comments stopped being on their own lines, now they should be restore back to the previous style.

New Features

  • Improved support for arrow functions when rendered in the markup.

Special thanks to: @korya.

Bug fixes

  • None

Maintenance

  • Test coverage remains at 100%
  • Updated dependencies.

Code Changes:

Allow settings to be stored in package.json

29 Aug 20:16
0d9b13a
Compare
Choose a tag to compare

Breaking changes to API

  • None

Breaking changes to snapshots

  • None

New Features

  • You can store your settings in your package.json now if you don't want to use the vue.config.js.
    • Fixes #79 Fixes #67
    • Allows users to customize settings without disrupting their more complex Vue-CLI configs, or having to create a dummy vue.config.js file when they are using Nuxt or not using Vue-CLI.

Special thanks to: @dschreij and @ataias.

Bug fixes

  • None

Maintenance

  • Test coverage remains at 100%
  • Updated dependencies.
  • Updated docs
  • Renamed master branch to main
  • Deleted coveralls/travis stuff
  • Improved GHA stuff
  • Added an automated coverage comment after each CI run
  • CI now runs on Node 16, still runs on Node 8.3, 10, 12, and 14 also

Code Changes:

Sorting Attributes is enabled by default

03 Apr 03:14
d7aa38c
Compare
Choose a tag to compare

Breaking changes to API

Breaking changes to snapshots

Attributes are now sorted by default.

-<div title="Good job" id="my-alert" class="success alert">
+<div class="success alert" id="my-alert" title="Good job">
   Good job
 </div>

New Features

  • Sorting attributes. This helps simplify diffs. Without sorting, a snapshot change could occur from just re-arranging the attributes, which could be very noisy, making it harder to see the more important changes of attributes missing or being added unintentionally.

Bug fixes

  • None

Maintenance

  • Test coverage remains at 100%
  • Updated dependencies.
  • Updated docs

Code Changes:

New API setting to clear Inline Functions from snapshots

07 Mar 22:12
7dc687d
Compare
Choose a tag to compare

Breaking changes to API

  • None.

Breaking changes to snapshots

  • None.

If you set clearInlineFunctions to true (false by default), then you will see diffs like this:

-<div something="function () {
-  /* more function code */
-  return true;
-}">
+<div something="[function]">

Special thanks to @cameron-martin and @luckylooke for finding and reporting the Istanbul issue.

New Features

  • New API setting to replace inline functions with a placeholder [function]. Disabled by default.
  • PERFORMANCE NOTE: I rearranged some code so that we do fewer transforms between static text and Cheerio objects for DOM/String manipulation of snapshots. This may give some minor performance improvements on large codebases with lots of snapshots.

Bug fixes

  • None.

Maintenance

  • Test coverage remains at 100%
  • Updated dependencies.
  • Updated docs

Code Changes:

A bandaid for Istanbul

04 Mar 13:29
03a0208
Compare
Choose a tag to compare

Breaking changes to API

  • None. Added new removeIstanbulComments setting to API which is enabled by default.

Breaking changes to snapshots

Previously, inline functions like this:

<div :title="function () { return true; }">

Would produce a snapshot with flags injected into it by Istanbul, if you were running Jest with --coverage.

<div title="function () {
  /* istanbul ignore next *\/
  cov_1lmjj6lxv1.f[3]++;
  cov_1lmjj6lxv1.s[15]++;
  return true;
}">

The random looking part of cov_1lmjj6lxv1.f[3]++; would change depending on the machine it was running on, breaking snapshot usability.
We now remove these inserted comments by default:

 <div title="function () {
-  /* istanbul ignore next *\/
-  cov_1lmjj6lxv1.f[3]++;
-  cov_1lmjj6lxv1.s[15]++;
   return true;
 }">

IMPORTANT NOTE: Since Istanbul modifies the DOM when Jest is ran with it, and does not when it is ran with --coverage=false, your snapshots that include inline functions will always fail when --coverage is not used (or --coverage=false is used). To learn more, and a potential workaround, see Issue #71.

PERFORMANCE NOTE: If you are not using inline functions and therefore not effected by this, you can change the removeIstanbulComments setting to false for potentially faster test runs.

Special thanks to @cameron-martin and @luckylooke for finding and reporting the Istanbul issue.

New Features

  • None

Bug fixes

  • None, unless you count putting a bandaid over Istanbul's bug.

Maintenance

  • Test coverage remains at 100%
  • Updated dependencies.
  • Updated docs

Code Changes:

Remove data-cy from snapshots

16 Oct 18:55
1e9e492
Compare
Choose a tag to compare

Breaking changes to API

  • none

Breaking changes to snapshots

The HTML parser we use got a major bump (4.1.0 -> 5.0.0). The only change I've notice is putting end tags on a new line. Which looks more like a bug-fix on their end.

 <div class="alert">
-  <!----> Success</div>
+  <!----> Success
+</div>

New Features

  • For those using Cypress for E2E testing, added the ability to optionally remove data-cy="whatever" from snapshots. This is disabled by default.

Bug fixes

  • None

Maintenance

  • Test coverage remains at 100%
  • Updated dependencies.
  • Updated docs

Code Changes:

Bug fix and performance increase

25 Mar 17:28
5423624
Compare
Choose a tag to compare

Breaking changes to API

  • none

Breaking changes to snapshots

  • In expectations that pass in a Vue wrapper (instead of using wrapper.html()) in projects that have addInputValues and stringifyObjects set to false (the defaults), tags without content that were previously on one line may now be broken up to two lines. This is due to the difference in how the wrapper was converted to HTML.
-<div class="example"></div>
+<div class="example">
+</div>

New Features

  • none

Bug fixes

  • There was a bug where all serializations were causing a VNode to be cloned if the user passed in a wrapper (rather than an string of the wrapper, wrapper.html()). This cloning should only occur if you are using the experimental features stringifyObjects or addInputValues.
  • These changes should improve performance for users not using these experimental features.
  • Snapshots that were breaking (that shouldn't have) during an upgrade to 3.12 or 3.13 should be fixed.

Maintenance

  • Test coverage remains at 100%

Code Changes:

Clear Attributes feature & Yarn partial support

21 Mar 20:54
3e5fbda
Compare
Choose a tag to compare

Breaking changes to API

  • none

Breaking changes to snapshots

  • none

New Features

  • You can now pass in an array of attributes to have their values cleared. This is useful when you have a particular attribute that is set to the random number for example. { attributesToClear: ['data-random'] }.
<div :data-random="Math.random()"></div>
-<div data-random="0.1407138529114249"></div>
+<div data-random></div>
  • Yarn users are now partially-supported. Although there is absolutely no reason to use Yarn after 2017 (npm is faster and supports the same features built in or via Node modules). So you really shouldn't be using it, but for those stuck at a job that forces you to use Less, Grunt, Yarn, CoffeeScript, or any other outdated technology, you have my sympathy. Hopefully this at least provides a path forward for these groups so they can slowly migrate towards better technologies. You've got Vue and Jest, so at least you're headed in the right direction.

Bug fixes

  • none

Maintenance

  • Test coverage remains at 100%
  • Updated dependencies
  • Updated documentation

Code Changes:

Input values visible in snapshots

16 Mar 00:05
4a7a7b2
Compare
Choose a tag to compare

Breaking changes to API

  • none

Breaking changes to snapshots

  • Improved stringifyObjects output. We now specifically handle different data types and output more accurate/useful string'd versions. Including many more data types than was previously handled.

Example of improvements:

<hr :title="new Date('2020')" />
-   <hr title="{}">
+   <hr title="1577836800000">

<hr :title="new Date('asdf')" />
-   <hr title="{}">
+   <hr title="Invalid Date">

<hr :title="new Error('err')" />
-   <hr title="{}">
+   <hr title="Error: err">

<hr :title="Infinity" />
-   <hr title="null">
+   <hr title="Infinity">

<hr :title="-Infinity" />
-   <hr title="null">
+   <hr title="-Infinity">

<hr :title="NaN" />
-   <hr title="null">
+   <hr title="NaN">

<hr :title="new Set(['a', 'b', 'b', 'c'])" />
-   <hr title="{}">
+   <hr title="['a','b','c']">

<hr :title="String" />
-   <hr title>
+   <hr title="Function">

<hr :title="undefined" />
-   <hr title>
+   <hr title="undefined">

New Features

  • There is now a verbose setting. This is set to true by default. Setting it to false will disable any console logs or errors from being output (not recommended, especially if using experimental features).
  • addInputValues is a new experimental feature to display the values of input elements as attributes in snapshots. This feature is disabled by default and requires you pass in a component wrapper, not an already flattened HTML string (wrapper not wrapper.html()). If your components are too large it will throw a max callstack exceeded error (this is why it is experimental, however on these components you can just pass in wrapper.html() to skip the feature on that snapshot).
-<input class="theme">
+<input class="theme" value="dark">
  • Note: In cases where a value would already be visible in the output, but does not give you information about what the current state of the input is, we add a v-model attribute instead of replacing the value attribute. Such as with radio dials:
-<input type="radio" value="cat">
-<input type="radio" value="dog">
+<input type="radio" value="cat" v-model="'dog'">
+<input type="radio" value="dog" v-model="'dog'">

Bug fixes

  • none

Maintenance

  • Added quote from Views on Vue podcast
  • Refactored many files to improve code quality and modularity.
  • Updated and improved documentation
  • Test coverage remains at 100%
  • Organized test files better
  • Set Travis-CI to use Node 8.3.0, the lowest version of Node this library supports, to ensure that support is not unintentially broken with the usage of newer JS features or dependency updates.
  • Updated dependencies
  • Improve tests

Code Changes:

Support Node 8.3+, improve docs

09 Feb 03:35
e46fa64
Compare
Choose a tag to compare

Breaking changes to API

  • none

Breaking changes to snapshots

  • none

New Features

  • Now supports Node 8.3.0+ (previously required Node 12+)
  • New Logo from the wonderful and talented Aurora Wooton

Bug fixes

  • none

Maintenance

  • Refactored a function to make it much simpler, and in the process allow for older Node versions to run the project
  • Re-write and reorganize the documentation
  • Test coverage remains at 100%

Code Changes: