using Jasmines spyon upon a private method

前端 未结 9 1620
轻奢々
轻奢々 2021-01-31 01:12

is it possible to use Jasmine unit testing framework\'s spyon method upon a classes private methods?

The documentation gives this example but can this be flexivble for a

9条回答
  •  星月不相逢
    2021-01-31 01:49

    Typescript gets compiled to javascript and in javascript every method is public. So you can use array index notation to access private methods or fileds, viz:

    Object['private_field']
    

提交回复
热议问题