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.
 
Francisco Presencia 094a060d55 Returning an array. Added docs and fixed tests 5 years ago
src Returning an array. Added docs and fixed tests 5 years ago
test Returning an array. Added docs and fixed tests 5 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 Returning an array. Added docs and fixed tests 5 years ago
package.json 3.0.0 7 years ago

README.md

react-jsdom

Render React components to 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');

const Hi = function ({ person }) {
  console.log('Hello there');
  return (
    <div>
      <span>hi</span>
      <span>{person}</span>
    </div>
  );
};

const elems = ReactJSDOM.render(<Hi person="mum"/>);
// console: 'Hello there'

elems[0].constructor.name
// 'HTMLDivElement'
elems[0].nodeName;
// 'DIV');
elems[0].querySelector('span:last-child').textContent;
// 'mum'
elems[0].outerHTML;
// <div>
//   <span>hi</span>
//   <span>mum</span>
// </div>

License

MIT © Luke Childs