Using Jasmine to spy on a function without an object

后端 未结 6 2067
挽巷
挽巷 2020-11-27 14:52

I\'m new to Jasmine and have just started using it. I have a library js file with lots of functions which are not associated with any object (i.e. are global). How do I go a

6条回答
  •  伪装坚强ぢ
    2020-11-27 15:53

    My answer differs slightly to @FlavorScape in that I had a single (default export) function in the imported module, I did the following:

    import * as functionToTest from 'whatever-lib';
    
    const fooSpy = spyOn(functionToTest, 'default');
    

提交回复
热议问题