Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wyze/preact-to-json
Convert Preact components to JSON.
https://github.com/wyze/preact-to-json
jest preact snapshot testing typescript
Last synced: about 2 months ago
JSON representation
Convert Preact components to JSON.
- Host: GitHub
- URL: https://github.com/wyze/preact-to-json
- Owner: wyze
- License: mit
- Created: 2017-05-16T12:32:40.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-01-26T17:01:32.000Z (about 7 years ago)
- Last Synced: 2024-11-21T22:35:48.807Z (2 months ago)
- Topics: jest, preact, snapshot, testing, typescript
- Language: TypeScript
- Homepage: https://npm.im/preact-to-json
- Size: 60.5 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Changelog: changelog.md
- License: license
Awesome Lists containing this project
README
# preact-to-json
[![Build Status][travis-image]][travis-url]
[![npm][npm-image]][npm-url]
[![devDependencies][depsdev-image]][depsdev-url]> Convert [Preact](//github.com/developit/preact) components to JSON.
_**Note:** This library currently only supports shallow rendering. If you need full (non-shallow) rendering, check out [nathancahill/preact-render-to-json](//github.com/nathancahill/preact-render-to-json)._
## Installation
```sh
$ yarn add --dev preact-to-json
```## Usage
```js
// ES6
import render from 'preact-to-json'// ES5
const { render } = require('preact-to-json')// With Jest
describe('Component', () => {
it('renders', () => {
const Component = () => (Google)
const element = render()expect(element).toMatchSnapshot()
})
})// test.snap
exports[`Component renders 1`] = `
`;
```## Change Log
> [Full Change Log](changelog.md)
### [v1.1.2](https://github.com/wyze/preact-to-json/releases/tag/v1.1.2) (2018-01-26)
* [[`7201875d00`](https://github.com/wyze/preact-to-json/commit/7201875d00)] - Handle when null/undefined children are rendered (Neil Kistner)
## License
MIT © [Neil Kistner](https://neilkistner.com)
[travis-image]: https://img.shields.io/travis/wyze/preact-to-json.svg?style=flat-square
[travis-url]: https://travis-ci.org/wyze/preact-to-json[npm-image]: https://img.shields.io/npm/v/preact-to-json.svg?style=flat-square
[npm-url]: https://npmjs.com/package/preact-to-json[depsdev-image]: https://img.shields.io/david/dev/wyze/preact-to-json.svg?style=flat-square
[depsdev-url]: https://david-dm.org/wyze/preact-to-json?type=dev