I have to test a Singleton but in his constructor i called a external method. How can i mock it ?
import externalLib from 'externalModule';
class MySingleton {
public _instance: MySingleton;
private constructor {
externalLib.method() // I have to mock externalLib
}
public getInstance() {
if (_instance) {
return _instance;
}
return new MySingleton();
}
}
export default MySingleton.getInstance();
Thank you.
Aucun commentaire:
Enregistrer un commentaire