-
-
Notifications
You must be signed in to change notification settings - Fork 349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve storing logs for the test suite run #605
Comments
Most test frameworks have a "focus" or "skip" type feature (i.e. in mocha you can add the suffix How would you like this to function? Should the log file ever be truncated or should it always be appended to, and the user should be responsible for deleting it? |
I think it would be good to have such flag in pact configuration like |
Jest pact helps this by giving each log file a different name, but you’re right-this could definitely be improved for the multi-suite use case. I think we could work out a better-by-default method that would avoid the need to introduce additional config options |
If you’re not using jest, then a workaround could be to instantiate one pact instance per suite- with different log files. (This is what jest-pact does) |
@TimothyJones , yep. Even if default behavior will be improved to store all logs per suite like described above with overwrite option it's will be enough. |
@danilchican what test runner are you using? |
@TimothyJones, jest |
Oh, right. Please check out https://github.com/pact-foundation/jest-pact - it solves this problem for you. |
@TimothyJones , are you talking about -> https://github.com/pact-foundation/jest-pact#defaults ? |
Apologies, looks like it's not in the documentation. I will correct that. If you start each mockserver on a different port and don't specify a log file, then the log file is named accordingly. |
@TimothyJones , did you add this already in the documentation? |
Sorry, preemptive send. I can’t seem to do a direct link on mobile. It’s in the defaults section of: https://github.com/pact-foundation/jest-pact |
@TimothyJones |
Ah, right. I see the problem. The Using jest-pact with common configThe intention for multiple specs with common configuration in
However, long term we'd like to introduce / expose the config in a first-class way - see here for a proposal. Solutions without migrating away from setupFilesA naive way would be to add a random string to the log filename, but it would be annoying to tie those to the specs, and you would have to ensure you clear out the log directory before you run the tests. I'll have a think about whether there's a way to write a As Matt said above, you can also work around this by running just the spec you're interested in - although we realise that's not ideal. Append log modeAs you said above, introducing an append log mode would also solve the problem in your case. Like the previous approach, a drawback would be that you'd have to ensure that the log files are cleaned out before running the tests. I'd really like the logs to work out of the box without extra config, though- making it configurable feels like we're leaking complexity to the user that would be better handled with sensible defaults (also- for technical reasons, adding this mode happens to not be a small change - but that doesn't mean we shouldn't do it, of course). Obviating the need for the logsAs an aside- soon we'll have better exposition of the diff during the output of a failed test, which will mean needing to read the log file will happen less frequently. |
Checklist
Before making a feature request, I have:
Feature description
Currently pact.log is replaced every time pact test has ran.
Let's imagine that you already have pact tests and add one more. In case if one of the tests will fail, pact logs file can do not store logs for the failed test. It stores logs just for the latest test which was run.
I think it could be better if the logs file will contain all logs within a run test suite instead of replacing each time after specific test running.
Use case
In our project I faced with the described issue when I tried to add one more pact test and after running test suite I see that some tests are failed and I want to debug what happened. But when I opened logs file I saw that it stores only latest test run logs (not all of them). It's hard to debug. You need to rename or remove all pact tests except of failed and run test suite again but even in that case if you have more than one failing tests - in logs file will be logs for the only one.
The text was updated successfully, but these errors were encountered: