I use ava to do integration tests by starting a separate node process for my express service, how should I go about correlating logs with ava? #3124
Replies: 4 comments
-
|
Also I came across this, have not tried to use it but I think I agree with the |
Beta Was this translation helpful? Give feedback.
-
|
I ended up doing this as a work around https://github.com/turnbasedgames/server/pull/74 |
Beta Was this translation helpful? Give feedback.
-
|
I've also tested services by starting them in a However I think it's still a rather niche and specific use case, not something that AVA should provide utilities for. I would be interested in having a reporting pipeline and low-level hooks to make this stuff possible though.
Perhaps in a world where there is more structured test output (not the default or the TAP reporters) that would be useful, but for now this can be done outside of AVA.
This seems hard to do in a generic fashion. With better reporting internals there could be hooks into that.
It's meant to be used during the hook or test execution. I see what you're saying, again we're limited by the current internals.
I can see the use in specific use cases. Again with better internals and structured output this would be more worthwhile. |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for the insight!
Yeah, totally agree here. Hopefully logging my use case for AVA is helpful to steer possible future design decisions and the product itself
Yes, this would be super helpful. I personally still need to add structured output for my logs for my services; this seems to help a ton when it comes to parsing and gleaning where to put logs, correlate them, APM, etc. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Context
Ava provides very nice test hooks (
before,after). I use thebeforehook to spawn a child process which is the service that I'm testing against.Here is a simple code snippet of how I've been trying to provide logs to AVA:
Log output of my service can be structured logs or logs that are prepended with a correlation id or
cid. Thiscidis an id that correlates with the specific integration test I'm running which is provided viax-cidheader when making requests.What I think the problem is
It is difficult to correlate logs coming from a separate process running concurrently to
avaWhat I think I want as a user
context, ava provides a unique integration test id that is maybe hashed from thet.title, and the id is accessible viat.id. I will use thist.idto put in my request headers when I'm hitting the test service.t.logwith acidthat it is able to correlate and put the log with the correct test logs (interweave them). At the end of the test, it prints out the output of the logs for that test.t.logshould default to log output related to a file if something is calling in any of the hooks after the hooks have been completed. Right now if you log int.beforeafter thet.beforecallback finishes, that log will never be printed out.t.logshould provide timestamps (not as related, but I wish it provided the timestamps when outputting)This feels relevant enough to be in
ava. What do you think? I also want to avoid starting a service per individual test because that feels really bulky, but maybe I'm wrong? Any feedback on my test strategy is also more than welcome and would love get criticism to improve this.Beta Was this translation helpful? Give feedback.
All reactions