首页 > 解决方案 > 如何以角度测试自定义事件气泡?

问题描述

如何以角度测试自定义事件气泡?如何测试自定义事件是否已发送?

testFn(detail) {
    this.test.dispatchEvent(
      new CustomEvent('custom-event', {
        detail,
        bubbles: true,
        composed: true,
      })
    );
  }

我该如何处理?

const spy1 = spyOn(component, 'testFn');
expect(spy1.calls.mostRecent()).toEqual(??);

标签: angular

解决方案


推荐阅读