Skip to content

Commit a225e95

Browse files
authoredOct 4, 2022
Merge pull request #795 from lamweili/code-coverage
test(#767): 100% code coverage
2 parents fa129dc + 9c5bd92 commit a225e95

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
 

‎test/supertest.js

+19
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,25 @@ describe('request(app)', function () {
759759
});
760760
});
761761

762+
// this scenario should never happen after https://github.com/visionmedia/supertest/pull/767
763+
// meant for test coverage for lib/test.js#287
764+
// https://github.com/visionmedia/supertest/blob/e064b5ae71e1dfa3e1a74745fda527ac542e1878/lib/test.js#L287
765+
it('_assertFunction should catch and return error', function (done) {
766+
const error = new Error('failed');
767+
const returnedError = get
768+
// private api
769+
._assertFunction(function (res) {
770+
throw error;
771+
});
772+
get
773+
.end(function () {
774+
returnedError.should.equal(error);
775+
returnedError.message.should.equal('failed');
776+
shouldIncludeStackWithThisFile(returnedError);
777+
done();
778+
});
779+
});
780+
762781
it(
763782
'ensures truthy non-errors returned from asserts are not promoted to errors',
764783
function (done) {

0 commit comments

Comments
 (0)
Please sign in to comment.