Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/lukechilds/react-jsdom

Render React components to actual DOM nodes in Node.js
https://github.com/lukechilds/react-jsdom

jsdom react test testing testing-tools

Last synced: 18 days ago
JSON representation

Render React components to actual DOM nodes in Node.js

Awesome Lists containing this project

README

        

# react-jsdom

> Render React components to actual DOM nodes in Node.js

[![Build Status](https://travis-ci.org/lukechilds/react-jsdom.svg?branch=master)](https://travis-ci.org/lukechilds/react-jsdom)
[![Coverage Status](https://coveralls.io/repos/github/lukechilds/react-jsdom/badge.svg?branch=master)](https://coveralls.io/github/lukechilds/react-jsdom?branch=master)
[![npm](https://img.shields.io/npm/v/react-jsdom.svg)](https://www.npmjs.com/package/react-jsdom)

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

## Install

```
npm install --save-dev react-jsdom
```

## Usage

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

class Hi extends React.Component {
render() {
return (


hi
{this.props.person}

);
}

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

const elem = ReactJSDOM.render();
// console: 'I mounted!'

elem.constructor.name
// 'HTMLDivElement'
elem.nodeName;
// 'DIV');
elem.querySelector('span:last-child').textContent;
// 'mum'
elem.outerHTML;
//


// hi
// mum
//

```

## License

MIT © Luke Childs