Skip to content
Advertisement

Mock object without fields and methods

I have for example:

JavaScript

Is possible to mock City object and still use street method as in other programming languages?

I would like to achieve something like this:

JavaScript

In short, I would like to mock the entire object so that it does not execute the constructor and that all fields and methods in the object work as before.

Advertisement

Answer

If you need everything else to occur but some_action, mock it to do nothing.

(so73635578 happens to be the name of this module. You’d replace it with wherever destroy_universe actually is.)

JavaScript

To wit:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement