Creating Custom Events

What strategies should be used for testing custom events?
describe('CustomEventComponent', () => {
  let component;
  let eventSpy;

  beforeEach(() => {
    component = document.createElement('custom-component');
    document.body.appendChild(component);
    eventSpy = jest.fn();
    document.addEventListener('custom-action', eventSpy);
  });

  it('should dispatch custom event with correct data', () => {
    component.triggerAction();
    
    expect(eventSpy).toHaveBeenCalledWith(
      expect.objectContaining({
        detail: expect.any(Object)
      })
    );
  });
});
Next Question (19/20)