Skip to content

Commit 28116f9

Browse files
authoredAug 17, 2021
Merge pull request #735 from benjosantony/master
Add on to the mitigation in https://github.com/visionmedia/supertest/…
2 parents b735b90 + ed0f68d commit 28116f9

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed
 

Diff for: ‎lib/test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ Test.prototype.expect = function(a, b, c) {
128128
}
129129

130130
// multiple statuses
131-
if (Array.isArray(a) && a.every(val => typeof val === 'number')) {
131+
if (Array.isArray(a) && a.length > 0 && a.every(val => typeof val === 'number')) {
132132
this._asserts.push(wrapAssertFn(this._assertStatusArray.bind(this, a)));
133133
return this;
134134
}

Diff for: ‎test/supertest.js

+11
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,17 @@ describe('request(app)', function () {
584584
.expect(['a', { id: 1 }], done);
585585
});
586586

587+
it('should support empty array responses', function (done) {
588+
const app = express();
589+
app.get('/', function (req, res) {
590+
res.status(200).json([]);
591+
});
592+
593+
request(app)
594+
.get('/')
595+
.expect([], done);
596+
});
597+
587598
it('should support regular expressions', function (done) {
588599
const app = express();
589600

0 commit comments

Comments
 (0)
Please sign in to comment.