Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: adding the whole response to verifyBody callback #487

Open
moty66 opened this issue Apr 24, 2023 · 1 comment
Open

Feature: adding the whole response to verifyBody callback #487

moty66 opened this issue Apr 24, 2023 · 1 comment

Comments

@moty66
Copy link
Contributor

moty66 commented Apr 24, 2023

For money reasons, it will be useful to access the original request and the whole response when verifying the body

const isFn = typeof this.opts.verifyBody === 'function'
if (isFn && !this.opts.verifyBody(resp.body)) {
  return this.emit('mismatch', resp.body)
} else if (!isFn && this.opts.expectBody && this.opts.expectBody !== resp.body) {
  return this.emit('mismatch', resp.body)
}

I think adding a second parameter to the callback verifyBody(resp.body, resp) will not break anything and will be useful for advanced body verifications

Can I make a pull request for this feature

@GlenTiki
Copy link
Collaborator

I think this should be doable but you’ll need to write a few in-depth test cases to verify edge cases, specifically if you verify the response asynchronously (think in a process.nextTick). I’m unsure of the object referenced stability where request object’s are reused for efficient execution, but it’s worth a try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants