diff --git a/lib/request.js b/lib/request.js index 719e99b..ec1c7a2 100644 --- a/lib/request.js +++ b/lib/request.js @@ -577,6 +577,7 @@ module.exports = { */ inspect: function(){ + if (!this.req) return; return this.toJSON(); }, diff --git a/lib/response.js b/lib/response.js index 07d8291..7c4f545 100644 --- a/lib/response.js +++ b/lib/response.js @@ -432,6 +432,7 @@ module.exports = { */ inspect: function(){ + if (!this.res) return; var o = this.toJSON(); o.body = this.body; return o; diff --git a/test/application.js b/test/application.js index f2c56df..324ea2b 100644 --- a/test/application.js +++ b/test/application.js @@ -61,6 +61,14 @@ describe('app.toJSON()', function(){ }) }) +describe('app.inspect()', function(){ + it('should work', function(){ + var app = koa(); + var util = require('util'); + var str = util.inspect(app); + }) +}) + describe('app.use(fn)', function(){ it('should compose middleware', function(done){ var app = koa();