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

Is there a way to skip asserting the request body? #39

Closed
jfhbrook opened this issue Feb 24, 2012 · 6 comments
Closed

Is there a way to skip asserting the request body? #39

jfhbrook opened this issue Feb 24, 2012 · 6 comments

Comments

@jfhbrook
Copy link

I was working on the new jitsu tests (nock is fabulous for this btw), and I came across an interesting situation when trying to mock snapshot uploads here:

https://github.com/nodejitsu/jitsu/blob/flatiron-apps-tests/test/commands/apps-test.js#L99

What happens here is that jitsu tries to post a snapshot using content-type chunked, and for the life of me I can't figure out how to specify a request body in such a way that nock is cool with it.

You can see some of the errors I was getting here:

https://gist.github.com/39d0e24897c8d339722a

The easiest thing for me would be to tell nock to accept any request body, but if I can figure out how to make it handle a chunked body (copy-pasting the string-encoded .tgz didn't help) I'd be happy with that as well.

Any ideas?

@theycallmeswift
Copy link
Contributor

I ended up doing a match to * and using the filteringRequestBody function to automatically convert everything to *

var scope = nock('http://api.myservice.com')
  .filteringRequestBody(function(path) {
    return '*';
  })
  .post('/some_uri', '*')
  .reply(200, 'OK')

@jfhbrook
Copy link
Author

That's awesome.

@pgte
Copy link
Member

pgte commented Mar 2, 2012

@jesusabdullah sorry, haven't been getting any emails on nock issues since I moved it to flatiron, even though I'm on the team :/

@jesusabdullah does this work for you or you think we should make it easier somehow?

@jfhbrook
Copy link
Author

jfhbrook commented Mar 2, 2012

@pgte Actually that trick worked just fine! It might be nice to have it in the readme as a PROTIP or something but otherwise, yeah, I'm good.

@jfhbrook jfhbrook closed this as completed Mar 2, 2012
@pgte
Copy link
Member

pgte commented Mar 2, 2012

@jesusabdullah good advise, thanks, updated README.

@lock
Copy link

lock bot commented Sep 14, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue and add a reference to this one if it’s related. Thank you!

@lock lock bot locked as resolved and limited conversation to collaborators Sep 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants