-
Notifications
You must be signed in to change notification settings - Fork 118
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
Logging middleware #125
Comments
Middleware like this is an interesting idea, especially if there were a publicly exported middleware creation function that provided a simple API for creating middleware that abstracted away all of the I will say that your use case might be better served with proper reporting functionality, though. See #27. |
You are right about the logging part. This is definitely not something you want to pollute your tests with. However, i got really excited about this idea of putting middleware layers between those callbacks. It opens up a lot of possibilities of drying up tests and improving their readability. I just recently started picking up TDD, so my awareness about the available tools is most likely insufficient. I know about Jest its mocking/stubbing features and its ability to output to JSON, but i don't know if they really solve the problem of drying up our tests. jest-cucumber also afforts an autobinding feature which to my awareness makes step definitions reusable on the test suite level? Providing an API to attach middleware to step definition handlers at multiple levels in the test suite hierarchy, would relate very well to the concept of Gherkin its backgrounds. It might be a good starting point to reason about any inconsistencies between Gherkin its concepts and the tooling jest-cucumber provides, in order to support these concepts. |
I definitely agree that some sort of a middleware / plug-in architecture in general would be helpful in this library. The goal with Jest Cucumber is to not stray too far from what people would expect from Jest and Cucumber, but at the same time, a lot of people have specific preferences or requirements that this library can't easily accommodate without imposing these opinions on everyone else.
In typical Jest tests, you use Some people would prefer that Jest Cucumber work more like Cucumber.js, which is what There are pros and cons to each approach, and it comes down to being a matter of preference, so I'd suggest you look over the docs / examples and decide which you prefer. Basically, do you prefer more Jest-like tests, or more Cucumber-like tests. |
Hi. I would like to propose adding additional utilities to this repo to support debugging. For example, something like below would be really beneficial in logging the return values of the step definition callbacks and manage the visibility of the logging statements. It could also serve other purposes like applying default assertions, but that might be out of scope for this repo.
EDIT:
I took the plunge to create a reusable middleware factory and it turned out pretty well. Its API is still a little crazy so that might need some extra work.
It then can be used to wrap the test definition.
Please let me know if anyone is interested in having this.
The text was updated successfully, but these errors were encountered: