From 9c5bd929112baa0248059350b58acfc8c3d6ff4e Mon Sep 17 00:00:00 2001 From: Lam Wei Li Date: Tue, 4 Oct 2022 07:06:36 +0800 Subject: [PATCH] test(#767): 100% code coverage --- test/supertest.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/supertest.js b/test/supertest.js index d6e6690..84fd22a 100644 --- a/test/supertest.js +++ b/test/supertest.js @@ -759,6 +759,25 @@ describe('request(app)', function () { }); }); + // this scenario should never happen after https://github.com/visionmedia/supertest/pull/767 + // meant for test coverage for lib/test.js#287 + // https://github.com/visionmedia/supertest/blob/e064b5ae71e1dfa3e1a74745fda527ac542e1878/lib/test.js#L287 + it('_assertFunction should catch and return error', function (done) { + const error = new Error('failed'); + const returnedError = get + // private api + ._assertFunction(function (res) { + throw error; + }); + get + .end(function () { + returnedError.should.equal(error); + returnedError.message.should.equal('failed'); + shouldIncludeStackWithThisFile(returnedError); + done(); + }); + }); + it( 'ensures truthy non-errors returned from asserts are not promoted to errors', function (done) {