question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inspecting request body?

See original GitHub issue

I am looking for a way to verify that the JSON in my request is structured properly for the API on the server. (I don’t want to match routes or methods against certain request parameters.) Is the only way to inspect the request data via the config.data property in the .reply() method?

For example, I’m doing something like this now:

mock.onPost().reply( ({data}) => { 
    expect(data.items.length).not.toBe(0);
    expect(data.title).toBe("my test title");
    // etc...
    done();
});

but using .reply() for this seems somewhat counterintuitive and I’m wondering if I’m missing something.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:5
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
ctimmermcommented, Mar 29, 2017

There’s no dedicated method for this, did you have something in mind as a proposal? I was thinking it could be like this:

mock.onPost()
  .do(config => {
    // do you expectations or other side effects here
  })
  // We can't just leave the request hanging and need to reply something
  .reply(200);
1reaction
ctimmermcommented, Jan 2, 2019

To verify if the request body is correct, history can be used.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Inspection of the request body, headers, and cookies
Mitigate the limitations on inspecting the web request body, headers, and cookies in AWS WAF.
Read more >
HTTP Request Body Inspection for Web Application Firewall
HTTP request body inspection instructs the web application firewall policy to buffer the request body in memory and inspect it before ...
Read more >
Inspect HTTP requests - Beeceptor Docs
Beeceptor enables you to collect, parse, and view HTTP requests. ... Use the endpoint's dashboard to inspect headers, request body, query strings, cookies, ......
Read more >
Simplest way to extract request body from POST request in ...
You can click on the "Network" tab, this will show you all of your requests and their responses.
Read more >
Modify request body inspection limit settings for a configuration
Beta. Modify request body inspection limit settings for a configuration. Inspect request bodies up to a certain size. In exceptional cases, you can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found