如何窥视茉莉花中的自定义事件?
  我定义了一个自定义事件。  我想用茉莉花监视它。  但是我遇到的问题是,当我使用spyOn来监视该事件时,它是失败的。  当我窥探一些功能时,它工作正常。  下面是我试过的: 
describe("Test:", function(){
    it("Expects event will be spied: ", function() {
        var eventSpy = spyOn(window, 'myEvent').andCallThrough();
        expect(eventSpy).toHaveBeenCalled();
        //Also tried this:
        //expect(eventSpy).not.toHaveBeenCalled();
    });
});
  所以我尝试了两个not.toHaveBeenCalled()和toHaveBeenCalled()但在两种情况下都失败了。  所以我猜spyOn无法窥探自定义事件。 
*注意:*我查看了其他类似问题的答案,但这与点击事件有关。 但在我的情况下,这是一个自定义事件,将自动根据一些条件被解雇。
尝试这样的事情。 为我工作
describe("Test:", function(){
it("Expects event will be spied: ", function() {
    var eventSpy = jasmine.createSpy();
    sampleElement.addEventListener('sample event', eventSpy);
    expect(eventSpy).toHaveBeenCalled();
});
