diff --git a/lib/test.js b/lib/test.js index 983eb6d..033c755 100644 --- a/lib/test.js +++ b/lib/test.js @@ -98,6 +98,7 @@ function wrapAssertFn(assertFn) { * .expect(200, body) * .expect('Some body') * .expect('Some body', fn) + * .expect(['json array body', { key: 'val' }]) * .expect('Content-Type', 'application/json') * .expect('Content-Type', 'application/json', fn) * .expect(fn) @@ -127,7 +128,7 @@ Test.prototype.expect = function(a, b, c) { } // multiple statuses - if (Array.isArray(a)) { + if (Array.isArray(a) && a.every(val => typeof val === 'number')) { this._asserts.push(wrapAssertFn(this._assertStatusArray.bind(this, a))); return this; } diff --git a/test/supertest.js b/test/supertest.js index 244b080..01dda4e 100644 --- a/test/supertest.js +++ b/test/supertest.js @@ -573,6 +573,17 @@ describe('request(app)', function () { }); }); + it('should support parsed response arrays', function (done) { + const app = express(); + app.get('/', function (req, res) { + res.status(200).json(['a', { id: 1 }]); + }); + + request(app) + .get('/') + .expect(['a', { id: 1 }], done); + }); + it('should support regular expressions', function (done) { const app = express();