0

Im doing some Unit testing to node application and I check for http response. currnlty I want to test also the http.header response for key and value which I send,what am I doing wrong ?

res.header.should.have.property['prop1'];
  1. Assume that I've prop1, how should I do that ?
  2. in addition how to assert to the value of prop1 ?
John Jerrby
  • 1,683
  • 7
  • 31
  • 68

2 Answers2

1

You should be calling property, not indexing into it:

res.header.should.have.property('prop1');

You can simultaneously check the value by passing it as a second argument:

res.header.should.have.property('prop1', 'propValue');
Aaron Dufour
  • 17,288
  • 1
  • 47
  • 69
0

You should try something like

res.header.prop1.should.equal('propValue');

This answer both...

Shimi Tal
  • 617
  • 5
  • 8