-
Notifications
You must be signed in to change notification settings - Fork 113
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
Remove TemplateRendererProxy mock #388
Remove TemplateRendererProxy mock #388
Conversation
✔️ No visual differences introduced by this PR. View Playwright Report (note: open the "playwright-report" artifact) |
Indeed, but if there is no usage of the dependency injection by the extension itself, wouldn't it be easy to understand (i.e., more intent-preserving) to use a mock here, even if it introduces extra lines of test code? |
Dependency injection is already used all over the place, even the Further, the only reason why the Even the async thing is only an unfortunate side effect of Handlebars not supporting async execution, which has had many unfortunate downstream effects and increase is code complexity, but that's not directly the issue here. |
Sure, I only meant to evaluate whether the dependency injection in this case was only being introduced to support testing as opposed to some functionality of the extension itself. Because if it only supports testing it would seem to me that would be clearer to use a mock (which puts the 'cognitive burden' of making sure the mock works on whoever writes the mock), as opposed to dependency injection (which puts the 'cognitive burden' on all modifiers of that part of the extension code that need to ensure their code will work with all the potential different valid dependencies that could be injected).
It sounds like you are saying there's a possibility this instance of dependency injection might be used by the extension itself? If so, then this seems fine to me. [BTW, I'm not too picky about this so happy to approve regardless, just wanted to share the thought.] |
Yeah I get ya, it is kinda intended to primarily support this test at this point in time I suppose, but that could change in the future given all of the other changes that have happened related to the Handlebars stuff. If My other thought on the mocking stuff is that it introduces new code which has to be maintained. The way it's done after this update should involve less burden as it's more direct. vitest mocks are also apparently some weird form of black magic where they are hoisted and apply to the imports in the file, but don't apply if you are importing it as a reference, so personally I also find it be more immediately clear what exactly is happening in the test. |
I think it'd be better for you to resolve the merge conflicts than me, so よろしく 🙇 |
e89f6e9
to
c419eae
Compare
The need for a mock can be removed by just using dependency injection.