Skip to content

Commit

Permalink
chore: fix flaky test
Browse files Browse the repository at this point in the history
  • Loading branch information
mmarchini committed Sep 29, 2021
1 parent 36318ae commit 6aac376
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions test/plugins/static.test.js
Expand Up @@ -350,19 +350,21 @@ describe('static resource plugin', function() {
directory: TMP_PATH
});

var socket = new net.Socket();
SERVER.get('/index.html', function(req, res, next) {
// closed before serve
serve(req, res, function(nextRoute) {
assert.strictEqual(nextRoute, false);
done();
socket.on('end', () => {
serve(req, res, function(nextRoute) {
assert.strictEqual(nextRoute, false);
done();
});
});
});
SERVER.on('after', function(req, res, route, afterErr) {
assert(afterErr.name, 'RequestCloseError');
done();
});

var socket = new net.Socket();
socket.connect({ host: '127.0.0.1', port: PORT }, function() {
socket.write(RAW_REQUEST, 'utf-8', function(err2, data) {
assert.ifError(err2);
Expand Down

0 comments on commit 6aac376

Please sign in to comment.