How to replace javascript method of super class for testing?

I want to test a method 'foo' that calls its super method 'foo':

     //do some extra stuff

If it would reference another method from the same class, e.g.

     //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')};;


However, how to replace 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


Answer = () => {
                        console.log('This is a mock of super foo');


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.