Fix test failures — closes #132

This commit is contained in:
Rich Harris
2018-03-03 14:33:47 -05:00
committed by GitHub
parent d9cb572271
commit a96fb93bfb
5 changed files with 1591 additions and 559 deletions

View File

@@ -5,26 +5,33 @@ import serve from 'serve-static';
import sapper from '../../../middleware';
import { routes } from './manifest/server.js';
let count;
let pending;
let ended;
process.on('message', message => {
if (message.action === 'start') {
count = 0;
if (pending) {
throw new Error(`Already capturing`);
}
pending = new Set();
ended = false;
process.send({ type: 'ready' });
}
if (message.action === 'end') {
ended = true;
if (count === 0) process.send({ type: 'done' });
if (pending.size === 0) {
process.send({ type: 'done' });
pending = null;
}
}
});
const app = express();
app.use((req, res, next) => {
count += 1;
if (pending) pending.add(req.url);
const { write, end } = res;
const chunks = [];
@@ -38,7 +45,7 @@ app.use((req, res, next) => {
if (chunk) chunks.push(new Buffer(chunk));
end.apply(res, arguments);
count -= 1;
if (pending) pending.delete(req.url);
process.send({
method: req.method,
@@ -48,7 +55,7 @@ app.use((req, res, next) => {
body: Buffer.concat(chunks).toString()
});
if (count === 0 && ended) {
if (pending && pending.size === 0 && ended) {
process.send({ type: 'done' });
}
};

View File

@@ -1,4 +1,4 @@
<!doctype>
<!doctype html>
<html lang='en'>
<head>
<meta charset='utf-8'>

File diff suppressed because it is too large Load Diff

View File

@@ -9,20 +9,20 @@
"prestart": "npm run build"
},
"dependencies": {
"compression": "^1.7.1",
"cross-env": "^5.1.1",
"css-loader": "^0.28.7",
"compression": "^1.7.2",
"cross-env": "^5.1.3",
"css-loader": "^0.28.10",
"express": "^4.16.2",
"extract-text-webpack-plugin": "^3.0.2",
"glob": "^7.1.2",
"marked": "^0.3.9",
"marked": "^0.3.17",
"node-fetch": "^1.7.3",
"npm-run-all": "^4.1.2",
"serve-static": "^1.13.1",
"serve-static": "^1.13.2",
"style-loader": "^0.19.0",
"svelte": "^1.49.1",
"svelte-loader": "^2.2.1",
"uglifyjs-webpack-plugin": "^1.1.2",
"webpack": "^3.10.0"
"svelte": "^1.56.0",
"svelte-loader": "^2.3.3",
"uglifyjs-webpack-plugin": "^1.2.2",
"webpack": "^3.11.0"
}
}