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.

Logging mocked requests

See original GitHub issue

Is there a possibility to add a console log for every request handled by the mock-adapter?

I know, that I can define a function for reply(), but I want to keep those as simple as possible. I also have an onAny() to handle undefined mock routes. What I want to achieve is to print a console log for each request handled by the mock adapter so I can see what data was sent to which endpoint.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:14
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
alexanderkjeldaascommented, Dec 17, 2019

@JsonHunt the main use-case for this is to have a quick&easy way of discovering the urls to mock. Your solution doesn’t help for the use-case.

4reactions
JsonHuntcommented, Aug 29, 2019

You can define your own method like this: var loggedGet = (url, response)=> { mock.onGet(url).reply((config)=> { console.log(“Mock request”, config) console.log(“Mock response”, response) return response }) } You would then call it instead of original mock.onGet: loggedGet(/permissions/, [200,permissions])

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mock API requests logging - Mockoon
Accessing the logs. For easier debugging, Mockoon records all entering requests and all the corresponding outgoing responses for each of your mock API....
Read more >
Logging & Debugging - MockServer
MockServer enables easy mocking of any system you integrate with via HTTP or HTTPS. ... A UI to easily view logs, active expectations,...
Read more >
Introducing Postman Mock Call Logs
With the new mock call logs feature, you can now see the details of the request and responses made to and from mock...
Read more >
Logging and mocking HTTP requests with TestCafe - Dan Purdy
A look into how to intercept, log and mock http requests within your end to end tests using TestCafe.
Read more >
How to log simple requests · Issue #568 · mock-server ...
Basically when I send requests to mock-server I would like to be able to have a debug.log from javascript for each request.
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