+ Start a Discussion
Varun kumar SaxenaVarun kumar Saxena 

How to test component events when event and handler are in different components?

In the reference jasmine test resource, component event(egComponentEvent) registration and handler is done in same component(egEventHandling).
Thus, we are able to test the result after event is fired.
     * Component under test: 'c:egEventHandling'
     * This spec shows how to validate a component's handling of component- and
     * application-level events.
    describe('c:egEventHandling', function() {
        it('handles component- and application-level events', function(done) {
            $T.createComponent("c:egEventHandling", null)
                var cmpEvent = component.getEvent("sampleEvent");
                cmpEvent.setParams({"data":"component event fired"});
                expect(component.get("v.message")).toBe("component event fired");
                $T.fireApplicationEvent("c:egApplicationEvent", {"data":"application event fired"});
                expect(component.get("v.message")).toBe("application event fired");
            }).catch(function(e) {
Facing issue to test the results after component event is fired, when event registration and its handler is done in different components.
We are firing a component level  event in component 1 and the handler is being invoked in Component 2 ,
We are struggling in testing component event where as component is getting fired but we are not able to see the handler invoked in the Component 2
Kindly help us in getting the correct solution for the below code
  .then(function(component) {
  var evt = component.getEvent('componentEvent');
  evt.setParam('entity', entity); 
Here event is getting fired from tagr_Tag but handler is not getting invoked from different component.
Please help us in arriving to the solution using any approach like spyon or something else.
Thanks in Advance