lundi 23 avril 2018

Test private function of module with mocha

I have

MyModule.ts

export module MyModule {
   export function f1() {...}
   function f2() {return true}
}

I am trying to write some unit tests and I want to test also function f2. Unfortunately

let myModule = rewire('./MyModule');
let f2Function = myModule.__get__('f2');

I get

ReferenceError: f2 is not defined.

How can I have access to private methods?

Aucun commentaire:

Enregistrer un commentaire