From 9d0976229d48c22e8f47dee6349bc4531035657f Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 4 Feb 2022 21:14:41 -0500 Subject: [PATCH] build: supertest@6.2.2 --- .github/workflows/ci.yml | 4 +-- appveyor.yml | 3 ++ package.json | 2 +- test/res.sendFile.js | 76 ++++++++++++++++++++++++---------------- 4 files changed, 52 insertions(+), 33 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 98314e57f8..c6eba737f9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,11 +59,11 @@ jobs: - name: Node.js 6.x node-version: "6.17" - npm-i: mocha@6.2.2 + npm-i: mocha@6.2.2 supertest@6.1.6 - name: Node.js 7.x node-version: "7.10" - npm-i: mocha@6.2.2 + npm-i: mocha@6.2.2 supertest@6.1.6 - name: Node.js 8.x node-version: "8.17" diff --git a/appveyor.yml b/appveyor.yml index 01e357f104..ca108e24fb 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -58,10 +58,13 @@ install: # supertest for http calls # - use 2.0.0 for Node.js < 4 # - use 3.4.2 for Node.js < 6 + # - use 6.1.6 for Node.js < 8 if ([int]$env:nodejs_version.split(".")[0] -lt 4) { npm install --silent --save-dev supertest@2.0.0 } elseif ([int]$env:nodejs_version.split(".")[0] -lt 6) { npm install --silent --save-dev supertest@3.4.2 + } elseif ([int]$env:nodejs_version.split(".")[0] -lt 8) { + npm install --silent --save-dev supertest@6.1.6 } # Update Node.js modules - ps: | diff --git a/package.json b/package.json index bc24d1a4f4..b3eedce29c 100644 --- a/package.json +++ b/package.json @@ -76,7 +76,7 @@ "multiparty": "4.2.2", "pbkdf2-password": "1.2.1", "should": "13.2.3", - "supertest": "6.1.6", + "supertest": "6.2.2", "vhost": "~3.0.2" }, "engines": { diff --git a/test/res.sendFile.js b/test/res.sendFile.js index 5f494f1e0b..183faceb1d 100644 --- a/test/res.sendFile.js +++ b/test/res.sendFile.js @@ -112,12 +112,11 @@ describe('res', function(){ app.use(function (req, res) { setImmediate(function () { res.sendFile(path.resolve(fixtures, 'name.txt')); - server.close(cb) setTimeout(function () { cb(error) }, 10) }) - test.abort(); + test.req.abort() }); app.use(function (err, req, res, next) { @@ -127,7 +126,10 @@ describe('res', function(){ var server = app.listen() var test = request(server).get('/') - test.end() + test.end(function (err) { + assert.ok(err) + server.close(cb) + }) }) describe('with "cacheControl" option', function () { @@ -272,43 +274,49 @@ describe('res', function(){ }) it('should invoke the callback when client aborts', function (done) { - var cb = after(1, done); + var cb = after(2, done) var app = express(); app.use(function (req, res) { setImmediate(function () { res.sendFile(path.resolve(fixtures, 'name.txt'), function (err) { - should(err).be.ok() - err.code.should.equal('ECONNABORTED'); - server.close(cb) + assert.ok(err) + assert.strictEqual(err.code, 'ECONNABORTED') + cb() }); }); - test.abort(); + test.req.abort() }); var server = app.listen() var test = request(server).get('/') - test.expect(200, cb); + test.end(function (err) { + assert.ok(err) + server.close(cb) + }) }) it('should invoke the callback when client already aborted', function (done) { - var cb = after(1, done); + var cb = after(2, done) var app = express(); app.use(function (req, res) { onFinished(res, function () { res.sendFile(path.resolve(fixtures, 'name.txt'), function (err) { - should(err).be.ok() - err.code.should.equal('ECONNABORTED'); - server.close(cb) + assert.ok(err) + assert.strictEqual(err.code, 'ECONNABORTED') + cb() }); }); - test.abort(); + test.req.abort() }); var server = app.listen() var test = request(server).get('/') - test.expect(200, cb); + test.end(function (err) { + assert.ok(err) + server.close(cb) + }) }) it('should invoke the callback without error when HEAD', function (done) { @@ -398,43 +406,49 @@ describe('res', function(){ }) it('should invoke the callback when client aborts', function (done) { - var cb = after(1, done); + var cb = after(2, done) var app = express(); app.use(function (req, res) { setImmediate(function () { res.sendfile('test/fixtures/name.txt', function (err) { - should(err).be.ok() - err.code.should.equal('ECONNABORTED'); - server.close(cb) + assert.ok(err) + assert.strictEqual(err.code, 'ECONNABORTED') + cb() }); }); - test.abort(); + test.req.abort() }); var server = app.listen() var test = request(server).get('/') - test.expect(200, cb); + test.end(function (err) { + assert.ok(err) + server.close(cb) + }) }) it('should invoke the callback when client already aborted', function (done) { - var cb = after(1, done); + var cb = after(2, done) var app = express(); app.use(function (req, res) { onFinished(res, function () { res.sendfile('test/fixtures/name.txt', function (err) { - should(err).be.ok() - err.code.should.equal('ECONNABORTED'); - server.close(cb) + assert.ok(err) + assert.strictEqual(err.code, 'ECONNABORTED') + cb() }); }); - test.abort(); + test.req.abort() }); var server = app.listen() var test = request(server).get('/') - test.expect(200, cb); + test.end(function (err) { + assert.ok(err) + server.close(cb) + }) }) it('should invoke the callback without error when HEAD', function (done) { @@ -652,12 +666,11 @@ describe('res', function(){ app.use(function (req, res) { setImmediate(function () { res.sendfile(path.resolve(fixtures, 'name.txt')); - server.close(cb) setTimeout(function () { cb(error) }, 10) }); - test.abort(); + test.req.abort() }); app.use(function (err, req, res, next) { @@ -667,7 +680,10 @@ describe('res', function(){ var server = app.listen() var test = request(server).get('/') - test.end() + test.end(function (err) { + assert.ok(err) + server.close(cb) + }) }) describe('with an absolute path', function(){