using Jasmines spyon upon a private method

前端 未结 9 1628
轻奢々
轻奢々 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:42

    const spy = spyOn(component, 'privateMethod');
    expect(spy).toHaveBeenCalled();
    

    To avoid lint warnings regarding object access via string literals, create a local constant of the spy object.

提交回复
热议问题