Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

preact-render-to-json

nathancahill2kMIT3.6.6

Render JSX and Preact components to JSON

preact, render, universal, isomorphic

readme

preact-render-to-json

npm CircleCI

Render JSX and Preact components to JSON. Useful for Jest Snapshot testing.

Usage with Jest

import preact from 'preact'
import render from 'preact-render-to-json'

/** @jsx preact.h */

let component = <div class="foo">content</div>;

test('component', () => {
    const tree = render(component)
    expect(tree).toMatchSnapshot()
})

License

MIT