react-test-renderer
    Overview
    Documentation
    Tutorials
    Insights
    Code
    Dependencies
    Contributors
    Jobs

react-test-renderer

React package for snapshot testing.

16.9.0  •  Updated 8 months ago  •  by facebook  •  MIT License

This package provides an experimental React renderer that can be used to render React components to pure JavaScript objects, without depending on the DOM or a native mobile environment.

Essentially, this package makes it easy to grab a snapshot of the “DOM tree” rendered by a React DOM or React Native component without using a browser or jsdom.

Documentation:

https://reactjs.org/docs/test-renderer.html

Usage:

const ReactTestRenderer = require('react-test-renderer');

const renderer = ReactTestRenderer.create(
  <Link page="https://www.facebook.com/">Facebook</Link>
);

console.log(renderer.toJSON());
// { type: 'a',
//   props: { href: 'https://www.facebook.com/' },
//   children: [ 'Facebook' ] }

You can also use Jest’s snapshot testing feature to automatically save a copy of the JSON tree to a file and check in your tests that it hasn’t changed: https://facebook.github.io/jest/blog/2016/07/27/jest-14.html.

Popularity

Weekly Downloads
2.3M
Stars
140.9K

Maintenance

Development

Last ver 8 months ago
Created 4 years ago
Last commit 4 months ago
5 hours between commits

Technology

Node version: 10.14.2
1447.4K unpacked

Compliance

MIT License
OSI Approved
0 vulnerabilities

Contributors

88 contributors
Brian Vaughn
380 commits, 64 merges, 56 PRs
Works at facebook
Dominic Gannaway
159 commits, 203 merges, 207 PRs
Works at facebook
Andrew Clark
119 commits, 121 merges, 144 PRs
Works at facebook
Dan Abramov
87 commits, 86 merges, 80 PRs
Works at facebook
Sebastian Markbåge
62 commits, 67 merges, 72 PRs
Works at Facebook
Nicolas Gallagher
43 commits, 67 merges, 72 PRs
Works at Facebook

Tags

react
react-native
react-testing
Openbase helps developers choose among and use millions of open-source packages, so they can build amazing products faster.
FacebookTwitterLinkedIn
© 2020 Devstore, Inc.