Logging mocked requests
See original GitHub issueIs 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:
- Created 6 years ago
- Reactions:14
- Comments:7 (1 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@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.
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])