Socket
Book a DemoInstallSign in
Socket

pretty-format-snabbdom

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pretty-format-snabbdom

pretty-format (Jest snapshot) plugin for snabbdom VNodes

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

pretty-format-snabbdom

pretty-format (Jest snapshot) plugin for snabbdom VNodes

build status AppVeyor build status code coverage

npm package license

Jest snapshots have greatly simplified testing the VDOM output of React components. If your application is based on the snabbdom virtual DOM implementation (like e.g. Cycle.js apps), you were previously out of luck, because snapshotting snabbdom VNodes would result in huge object descriptions that were hard to read.

pretty-format-snabbdom makes Jest snapshots of snabbdom VNodes look just as pretty as those of React elements, using pretty-formats plugin system.

Usage

npm install --save-dev pretty-format-snabbdom

Register in your .jestrc:

{
  "snapshotSerializers": ["pretty-format-snabbdom"]
}

or right in your test files:

import prettyFormatSnabbdom from 'pretty-format-snabbdom';
expect.addSnapshotSerializer(prettyFormatSnabbdom);

Before

Object {
  "children": Array [],
  "data": Object {
    "data": Object {
      "stuff": "stuff",
    },
    "ns": undefined,
    "props": Object {
      "className": "cl",
      "id": "id",
      "onclick": [Function],
      "title": "title",
    },
    "style": "color: black;",
  },
  "key": undefined,
  "sel": "div",
}

After

<div
  style="color: black;"
  data={
    Object {
      "stuff": "stuff",
    }
  }
  id="id"
  className="cl"
  title="title"
  onclick={[Function]}
/>

Keywords

pretty-format

FAQs

Package last updated on 24 Nov 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts