Skip to content

Commit

Permalink
Add server response log when status code error
Browse files Browse the repository at this point in the history
  • Loading branch information
WarleyGabriel committed Feb 1, 2021
1 parent 1bb8c66 commit d1c2c2a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"no-underscore-dangle": [0],

// IMHO, more sensible overrides to existing airbnb error definitions
"max-len": [2, 100, 4, {"ignoreComments": true, "ignoreUrls": true}],
"max-len": [2, 115, 4, {"ignoreComments": true, "ignoreUrls": true}],
"no-unused-expressions": [2, { "allowShortCircuit": true, "allowTernary": true }]
}
}
4 changes: 3 additions & 1 deletion lib/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,9 @@ Test.prototype._assertStatus = function(status, res) {
if (res.status !== status) {
a = http.STATUS_CODES[status];
b = http.STATUS_CODES[res.status];
return new Error('expected ' + status + ' "' + a + '", got ' + res.status + ' "' + b + '"');
return new Error(
`expected ${status} "${a}", got ${res.status} "${b}", with response: ${JSON.stringify(res, null, 2)}`
);
}
};

Expand Down
12 changes: 9 additions & 3 deletions test/supertest.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,9 @@ describe('request(app)', function () {
.get('/')
.expect(404)
.end(function (err, res) {
err.message.should.equal('expected 404 "Not Found", got 200 "OK"');
err.message.should.equal(
`expected 404 "Not Found", got 200 "OK", with response: ${JSON.stringify(res, null, 2)}`
);
shouldIncludeStackWithThisFile(err);
done();
});
Expand Down Expand Up @@ -466,7 +468,9 @@ describe('request(app)', function () {
.expect(200)
.expect('hey')
.end(function (err, res) {
err.message.should.equal('expected 200 "OK", got 500 "Internal Server Error"');
err.message.should.equal(
`expected 200 "OK", got 500 "Internal Server Error", with response: ${JSON.stringify(res, null, 2)}`
);
shouldIncludeStackWithThisFile(err);
done();
});
Expand Down Expand Up @@ -1038,7 +1042,9 @@ describe('assert ordering by call order', function () {
.expect(200)
.expect('hey')
.end(function (err, res) {
err.message.should.equal('expected 200 "OK", got 500 "Internal Server Error"');
err.message.should.equal(
`expected 200 "OK", got 500 "Internal Server Error", with response: ${JSON.stringify(res, null, 2)}`
);
shouldIncludeStackWithThisFile(err);
done();
});
Expand Down

0 comments on commit d1c2c2a

Please sign in to comment.