react-test-renderer
React package for snapshot testing.
Last updated 3 years ago by gnoff .
MIT · Repository · Bugs · Original npm
$ cnpm install react-test-renderer 
SYNC missed versions from official npm registry.

react-test-renderer

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://jestjs.io/blog/2016/07/27/jest-14.html.

Current Tags

  • 0.0.0-57333ca33                                ...           canary (6 years ago)
  • 0.0.0-experimental-33c3af284                                ...           experimental (5 years ago)
  • 18.2.0                                ...           latest (3 years ago)
  • 18.3.0-next-4ea063b56-20221101                                ...           next (3 years ago)
  • 0.0.0-da834083c                                ...           unstable (5 years ago)

17 Versions

  • 18.3.0-next-4ea063b56-20221101                                ...           3 years ago
  • 18.2.0                                ...           3 years ago
  • 18.0.0-rc.3                                ...           3 years ago
  • 18.2.0-next-a2505792e-20220524                                ...           3 years ago
  • 18.1.0                                ...           3 years ago
  • 18.0.0-beta-24dd07bd2-20211208                                ...           4 years ago
  • 17.0.2                                ...           4 years ago
  • 16.14.0                                ...           5 years ago
  • 0.0.0-da834083c                                ...           5 years ago
  • 0.0.0-33c3af284                                ...           5 years ago
  • 0.0.0-experimental-33c3af284                                ...           5 years ago
  • 0.0.0-57333ca33                                ...           6 years ago
  • 15.6.1                                ...           8 years ago
  • 15.5.4                                ...           8 years ago
  • 16.12.0                                ...           6 years ago
  • 15.6.2                                ...           8 years ago
  • 16.13.1                                ...           5 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (3)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2013 - present © cnpmjs.org