Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
Douglas Eugene Reisinger II

Is it possible to monkey patch a base class with es6 for testing purposes? Say I have a contorller Foo and it extends the class BaseController. I want to swap out BaseController for MockBaseController in my unit tests... thoughts?

I'm pretty sure I can require BaseController first, and reassign it to the mock, and then instantiate Foo, but I'm not positive

Hmm, I guess this isn't the best place for this question, my apologies.
Rhys van der Waerden
@palodequeso it's possible to reassign Object#__proto__. This will change the inheritance chain of your instance.
However, it sounds like you probably shouldn't be using inheritance.
Eduard Jacko
This message was deleted