Skip to content

Commit

Permalink
Start setup of react-server-cli integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
karlhorky committed Jan 16, 2017
1 parent dec327b commit 5c26c0a
Show file tree
Hide file tree
Showing 22 changed files with 146 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/react-server-cli/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
target
test/tmp
15 changes: 12 additions & 3 deletions packages/react-server-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"prepublish": "gulp",
"lint": "gulp eslint",
"test": "npm run ava && gulp test && nsp check",
"ava": "ava test",
"ava": "ava",
"ava-watch": "ava --watch",
"clean": "rimraf target npm-debug.log*"
},
"author": "Sasha Aickin",
Expand Down Expand Up @@ -60,14 +61,22 @@
"gulp-babel": "^6.1.2",
"gulp-eslint": "^3.0.1",
"nsp": "^2.6.2",
"react": "^15.4.2",
"react-dom": "^15.4.2",
"react-hot-loader": "^1.3.1",
"react-server": "^0.5.1",
"react-server-gulp-module-tagger": "^0.4.10",
"rimraf": "^2.5.4"
"rimraf": "^2.5.4",
"superagent": "^1.8.4"
},
"ava": {
"require": [
"babel-core/register"
],
"tap": true
"tap": true,
"files": [
"test/**/*.js",
"!test/fixtures/*.js"
]
}
}
29 changes: 29 additions & 0 deletions packages/react-server-cli/test/commands.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import path from 'path';
import fs from 'fs';
import child_process from 'child_process';
import test from 'ava';
import rimraf from 'rimraf';

const tmpPath = path.join(__dirname, 'tmp');

// function clear(){
// process.chdir(__dirname);
// if (fs.existsSync(tmpPath)) rimraf.sync(tmpPath);
// fs.mkdirSync(tmpPath);
// process.chdir(tmpPath);
// }

test('test', async t => {
process.chdir(`${__dirname}/fixtures/commands/start-basic/in-files`);
const server = child_process.spawn(process.execPath, [path.join(__dirname, '..', 'bin', 'react-server-cli'), 'start']);

server.stderr.on('data', stderr => process.stderr.write(stderr));
server.stdout.on('data', stdout => process.stdout.write(stdout));

await new Promise(resolve => {
setTimeout(() => {
resolve();
server.kill();
}, 3000);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"middleware": [],
"routes": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"args": ["start"]
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"presets": [
"react-server"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"routesFile": "routes.json",
"port": 3000,
"env": {
"production": {
"port": 80
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"jsChunksByName":{"common":"common.bundle.js"},"jsChunksById":{"0":"common.bundle.js"},"cssChunksByName":{},"hash":"d8bf2572a3f704ae8f83"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

if (typeof window !== "undefined") {
window.__setReactServerBase = function(path) {
// according to http://webpack.github.io/docs/configuration.html#output-publicpath
// we should never set __webpack_public_path__ when hot module replacement is on.
if (!module.hot) {
__webpack_public_path__ = path;
}
window.__reactServerBase = path;
}
}
var reactServer = require("react-server");
window.rfBootstrap = function() {
reactServer.logging.setLevel('main', "debug");
reactServer.logging.setLevel('time', "fast");
reactServer.logging.setLevel('gauge', "ok");
new reactServer.ClientController({routes: require("./routes_client")}).init();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

var manifest = undefined;
function unwrapEs6Module(module) { return module.__esModule ? module.default : module }
var coreJsMiddleware = require('/Users/karlhorky/projects/kaytcat-react-server/packages/react-server-cli/node_modules/react-server-core-middleware/index.js').coreJsMiddleware;
var coreCssMiddleware = require('/Users/karlhorky/projects/kaytcat-react-server/packages/react-server-cli/node_modules/react-server-core-middleware/index.js').coreCssMiddleware;
module.exports = {
middleware:[
coreJsMiddleware(null, manifest),
coreCssMiddleware(null, manifest),

],
routes:{
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

var manifest = {"jsChunksByName":{"common":"common.bundle.js"},"jsChunksById":{"0":"common.bundle.js"},"cssChunksByName":{},"hash":"d8bf2572a3f704ae8f83"};
function unwrapEs6Module(module) { return module.__esModule ? module.default : module }
var coreJsMiddleware = require('/Users/karlhorky/projects/kaytcat-react-server/packages/react-server-cli/node_modules/react-server-core-middleware/index.js').coreJsMiddleware;
var coreCssMiddleware = require('/Users/karlhorky/projects/kaytcat-react-server/packages/react-server-cli/node_modules/react-server-core-middleware/index.js').coreCssMiddleware;
module.exports = {
middleware:[
coreJsMiddleware("http://localhost:3001/", manifest),
coreCssMiddleware("http://localhost:3001/", manifest),

],
routes:{
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"babel-preset-react-server": "^0.4.10",
"react": "^15.4.2",
"react-dom": "^15.4.2",
"react-server": "^0.5.1",
"superagent": "^1.8.4"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"middleware": [],
"routes": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"args": ["start"]
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"routesFile": "routes.js"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"args": ["start"]
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
undeclaredVariable();
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"args": ["start", "--routes-file", "routes.js"]
}
Empty file.

0 comments on commit 5c26c0a

Please sign in to comment.