Skip to content

Commit

Permalink
Fix node tests
Browse files Browse the repository at this point in the history
finalhandler returns a request body that we do not expect. Use a simple 404 instead.
  • Loading branch information
brycekahle committed Aug 2, 2020
1 parent 030c66b commit a098d4e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -37,7 +37,6 @@
"envify": "^4.0.0",
"eslint": "^7.6.0",
"expect.js": "~0.3.1",
"finalhandler": "^1.1.2",
"gulp": "^4.0.2",
"gulp-header": "^2.0.9",
"gulp-rename": "^2.0.0",
Expand Down
8 changes: 5 additions & 3 deletions tests/support/sockjs_server.js
Expand Up @@ -3,7 +3,6 @@

var http = require('http');
var serveStatic = require('serve-static');
var finalhandler = require('finalhandler');
var sockjs = require('./sockjs_app');
var url = require('url');
var path = require('path');
Expand All @@ -19,7 +18,7 @@ function startServer(port, config, prefix) {
}
};

var serve = serveStatic(path.join(__dirname, '../html'));
var serve = serveStatic(path.join(__dirname, '../html'), { fallthrough: false });

var server = http.createServer();
server.addListener('request', function(req, res) {
Expand Down Expand Up @@ -53,7 +52,10 @@ function startServer(port, config, prefix) {
res.end('var clientOptions = ' +
JSON.stringify(clientOptions) + ';');
} else {
serve(req, res, finalhandler(req, res));
serve(req, res, function(err) {
var status = err ? err.statusCode : 404;
return res.writeHead(status).end();
});
}
});
server.addListener('upgrade', function(req, res){
Expand Down

0 comments on commit a098d4e

Please sign in to comment.