Created
May 19, 2016 15:53
-
-
Save StJohn3D/b3ff64146e976eb3fe7758bdc2893677 to your computer and use it in GitHub Desktop.
Quickly convert react components to jQuery like Cheerio objects for testing - source code from cheerio-react on npm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ReactDOMServer = require('react-dom/server'); | |
var cheerio = require('cheerio'); | |
module.exports = function( reactClass ) { | |
var staticMarkup = ReactDOMServer.renderToStaticMarkup(reactClass); | |
var $ = cheerio.load(staticMarkup); | |
return $.root().children().first(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment