AmadeusITGroup / kassette

kassette is a development server, used mainly for testing, which proxies requests and is able to easily manage local mocks.
MIT License
8 stars 15 forks source link

Mock server calls recording #489

Open KayleighYum opened 6 months ago

KayleighYum commented 6 months ago

Would it be possible to support recording all calls made to the server? The recording would store the request url, method and body (if exists) The reasons for this would be:

divdavem commented 5 months ago

Hi @KayleighYum Thank you for opening this issue. It is already possible to do whatever recording you need by implementing the hook function in the config. You can, for example, store in a file the information you want to check about each request, or if you run kassette from the same process as your (node.js-based) test runner, you can even do the recording in a js object in memory only and access the same object from your test. Would this work for your use case?

KayleighYum commented 5 months ago

Hi @divdavem we currently have a worker running the mock server and another one running our tests. We're have specified certain endpoints to the mock server to return/alter state that we're storing in the mock server. This is working fine but we were wondering if this could be improved.

Previous iterations of this was using the onListen hook to start up a readiness server and then used that server for state management.

divdavem commented 5 months ago

Thank you for your answer!

This is working fine but we were wondering if this could be improved.

I like the way you implemented it. :+1: How would you improve it? What would you expect from the improved solution?

KayleighYum commented 5 months ago

Currently we're using the hook method to check if the place starts with certain keywords, wrapping the state in a payload and using the hook to return the response from the payload. It's a very hardcoded if/else statement that could become finicky later on

It would be great if it could come from the package for others to use. Is this something that is in scope?