All Projects → nathancahill → preact-render-to-json

nathancahill / preact-render-to-json

Licence: other
Render JSX and Preact components to JSON

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].