mcollina / autocannon

fast HTTP/1.1 benchmarking tool written in Node.js
MIT License
7.83k stars 325 forks source link

One small question with expectbody #373

Open MasonEast opened 3 years ago

MasonEast commented 3 years ago

I want to use expectbody, but it supports String, and I looked at your source code and it does:

if (this.opts.expectBody && this.opts.expectBody !== resp.body) {
      return this.emit('mismatch', resp.body)
}

The return body of my interface is an object. Your rules will very hard match. Why not use this:

if (this.opts.expectBody && !resp.body.includes(this.opts.expectBody)) {
      return this.emit('mismatch', resp.body)
}
mcollina commented 3 years ago

Would you like to send a Pull Request to address this issue? Remember to add unit tests.

MasonEast commented 3 years ago

Yes, it's my pleasure

MasonEast commented 3 years ago

Hello, I simply added assertions to autocannon. pr has been mentioned