UNPKG

@helpscout/cyan

Version:

Cypress-like Testing for React + JSDOM

25 lines (20 loc) 710 B
"use strict"; var cheerio = require('cheerio'); var fs = require('fs'); var path = require('path'); module.exports = { '/': { get: function get(req, res) { var file = req.query.file; var filepath = path.join(process.cwd(), '/node_modules/.cyan', file || 'index.html'); fs.readFile(path.join(filepath), 'utf-8', function (err, data) { if (err) { return res.end(filepath + " is invalid"); } var $ = cheerio.load(data); $('body').append("\n <script src=\"/socket.io/socket.io.js\"></script>\n <script>\n var socket = io();\n </script>\n "); return res.end($.html()); }); } } };