npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue3-snapshot-serializer

v0.0.1

Published

Vitest snapshot serializer for Vue 3 components

Downloads

68

Readme

Vue 3 Snapshot Serializer

Vue 3 Snapshot Serialization for Vitest and Jest.

This is the future successor to jest-serializer-vue-tjw.

Goal

Re-write jest-serializer-vue-tjw from the ground up (copying some stuff over as needed).

Plan

  1. New repo tech stack:
    • ESM import
    • Vite + Vitest + Vitest snapshots
    • Vue 3
    • GHA - Linting/Unit tests
  2. Settings will now be stored differently:
    • Settings no longer stored in files (package.json, vue.config.js, vite.config.js, etc.)
    • Instead globalThis.vueSnapshots = {}; will be used for settings.
    • This allows users to define settings in their global.beforeEach() in their settings file.
    • Also makes it much easier to override these global settings when you have test-specific settings.
    • Would be be nice to abstract the settings gathering from the serialization, so the serialization can be externalized.
      • serializeVue(htmlOrVueWrapper, settings);
      • Would allow E2E tooling to import and use this directly (See #70)
    • The library would need to clear this global setting after every run to prevent global object-mutation based test-bleed.
  3. Migration guide
  4. Once feature support reaches an acceptable point, update the old repo to point people to this one.
    • Place deprecation warning
    • Point to migration guide, maybe migration guide should just live in the old repo and be linked to from the new one?

Planned API Support:

This is mostly take from jest-serializer-vue-tjw:

Setting | In new version? | Description :-- | :-- | :-- formatting | Yes, may change | Formmating options object, including new "diffable html" options removeDataVId | Yes | Removes data-v-1234abcd="" from your snapshots removeComments | Yes | Removes all HTML comments removeDataTest | Yes | Removes data-test="whatever" from your snapshots removeDataTestid | Yes | Removes data-testid="whatever" from your snapshots removeDataTestId | Yes | Removes data-test-id="whatever" from your snapshots removeDataQa | Yes | Removes data-qa="whatever" from your snapshots removeDataCy | Yes | Removes data-cy="whatever" from your snapshots (Cypress) removeDataPw | Yes - New | Removes data-pw="whatever" from your snapshots (Playwright) removeServerRendered | Yes | Removes data-server-rendered="true" from your snapshots sortAttributes | Eventually | Sorts the attributes inside HTML elements in the snapshot. May not be in first release of v4 attributesToClear | Probably | Array of attribute strings to remove the values from. ['title', 'id'] produces <input title id class="stuff"> verbose | Probably | Logs to the console errors or other messages if true removeClassTest | Maybe | Removes all CSS classes that start with "test", class="test-whatever" removeIdTest | Maybe | Removes id="test-whatever" or id="testWhatever"from snapshots removeIstanbulComments | Maybe | Removes /* istanbul ignore next */ cov_1lmjj6lxv1.f[3]++; comments from snapshots. This may not be an issue in the new tech stack? clearInlineFunctions | Maybe | <div title="(x) => !x"> becomes <div title="[function]"> addInputValues | No | Display form field value. <input> becomes <input value="whatever">. Not sure how to do this in Vue 3 stringifyObjects | No | Replaces title="[object Object]" with title="{a:'asdf'}". Not sure if this is possible in Vue 3

New planned features

Not in jest-serializer-vue

  • Remove Playwright tokens (data-pw="whatever)
  • Diffable HTML (See #85)
  • Support for E2E tooling like Playwright (see #70)