I want to test a method 'foo' that calls its super method 'foo':
foo(){
super.foo();
//do some extra stuff
}
If it would reference another method from the same class, e.g.
foo(){
this.baa();
//do some extra stuff
}
... i could simply replace the baa method for testing, e.g
element.baa = () => { console.log('This is a mock of baa')};
element.foo();
expect(effectsOfFoo).toBe(Ok).
However, how to do the same for the super method 'foo'?
Maybe something like
element.constructor.getSuperClass().foo = () => { console.log('This is a mock of super foo')};
However, I did not manage to get the super class, yet.
Related questions:
spying on/mocking super class methods in es6
Aucun commentaire:
Enregistrer un commentaire