You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
Luke Childs 018f03d3e2 Fix incorrect module name in example 8 years ago
src There will only be one child 8 years ago
test Test componentDidMount fires 8 years ago
.gitignore Initial commit 8 years ago
.travis.yml JSDOM only supports Node 6 and up so that;s all we can support 8 years ago
LICENSE Initial commit 8 years ago
README.md Fix incorrect module name in example 8 years ago
package.json 2.0.2 8 years ago

README.md

react-jsdom

Render actual DOM nodes in Node.js

Build Status Coverage Status npm

Makes testing simple React components super easy with any Node.js test framework.

Install

npm install --save-dev react-jsdom

Usage

const React = require('react');
const ReactJSDOM = require('react-jsdom');

class Hi extends React.Component {
  render() {
    return (
      <div>
        <span>hi</span>
        <span>{this.props.person}</span>
      </div>
    );
  }

  componentDidMount() {
    console.log('I mounted!');
  }
}

const elem = ReactJSDOM.render(<Hi person="mum"/>);
// I mounted!

elem.nodeName;
// 'DIV');
elem.querySelector('span:last-child').textContent;
// 'mum'
elem.outerHTML;
// <div>
//   <span>hi</span>
//   <span>mum</span>
// </div>

License

MIT © Luke Childs