-
-
Notifications
You must be signed in to change notification settings - Fork 770
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
Feature Request: Add API support to stub a parent class constructor. #2578
Comments
What about just wrapping the code I provided in a utility called Just a tip: try writing the docs for the feature (describing the API, the context and how to use it) before writing the code and tests. It helps in solidifying a good API. |
That does help, actually. Thanks.
You've already helped me a lot, but I'm also looking for feedback on the premise of this proposal. The contribution guide says:
I don't have a lot of GitHub knowledge/experience; have you given me the feedback I need to attempt this or should I get signoff from someone else first?
Good advice. By just thinking about the first step, I'm wondering if it should be |
I am not totally sure which parameters are supposed be passed into
What would |
After reading your thoughts, I 100% agree. Please ignore that idea. |
I'm still open to this, btw. We just need to find an API that seems meaningful. |
Is your feature request related to a problem? Please describe.
I've seen a lot of questions asking how to stub a parent class's constructor. @fatso83 provides a solution here, but it is written in plain JavaScript. Unless you are searching the sinon github repository, this solution is hard to find.
It's written in vanilla js, meaning the prototype's lifecycle must be managed by the developer: they have to undo the
Object.setPrototypeOf
change or the child class's prototype will remain modified, causing test pollution.Describe the solution you'd like
I would like sinon to provide a way to stub a parent class constructor with its API. That way, sinon can manage the prototype lifecycle like it manages other test double lifecycles.
Describe alternatives you've considered
sinon.createStubInstance
could be expanded to support this use case?Additional context
The text was updated successfully, but these errors were encountered: