node.js - Difficulty in Testing Response Header Fields Other Than Status Code -
I am using Express Framework (Node.js code works as shown below and I return to the title Can see your customized message) to retrieve a collection from the database and return the response header to the customer to put a customized message:
if (req.accepts ('json') ) {** res.header ('warning', 'my_customized_message'); ** res.header ('content-type', 'application / json'); Res.send (res.locals.items, 200); } Now, I try to use "MOCHA" to test this line unit of newly added code using MOCHA:
Requires Request = ('Request'); Should = need ('should'); Description ('received / core / dbq / 534e930204dd311822ec1c9d', function () {this.timeout (15000), this ('check header message', function (done) {request.get ('http: // localhost: 3001 / ecrud / v1 / core / dbq / 534e930204dd311822ec1c9d ', function (hey, feedback, header) {response.statusCode.should.equal (200); response.warning.should.equal (' my_customized_message '); // Uncaught TypeError: not read Undetermined ();}}}}}} of the property 'should'. If I test the response. Directcodes are only, no problem, Moka test successfully passed but , If i Warning, I get an error saying that the property is not 'defined' (I must run NPM --save-dev). It seems that the "warning" to the area of "reaction" But it is one of the "Warning" response fields.
If I try to check the reaction content type, then it is such a mistake. Cars "is a very well-known response header field. Anyway, who is actually interested in testing the "Warning" header please help. Thank you.
I think that you want instead ( response is one) ): Feedback Ideas. Warning.Sold.Egle ('my_customized_message');
Comments
Post a Comment