Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/lukechilds/react-jsdom
- Owner: lukechilds
- License: mit
- Created: 2017-08-10T19:14:25.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2021-08-12T23:49:05.000Z (about 3 years ago)
- Last Synced: 2024-10-20T14:34:52.142Z (19 days ago)
- Topics: jsdom, react, test, testing, testing-tools
- Language: JavaScript
- Homepage:
- Size: 15.6 KB
- Stars: 33
- Watchers: 3
- Forks: 8
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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