1

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.

https://github.com/forcedotcom/LightningTestingService/blob/master/lightning-component-tests/test/default/staticresources/jasmineExampleTests.resource

/**
     * 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)
            .then(function(component){
                var cmpEvent = component.getEvent("sampleEvent");
                cmpEvent.setParams({"data":"component event fired"});
                cmpEvent.fire()
                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");
                done();
            }).catch(function(e) {
                done.fail(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

 $T.createComponent("c:tagr_Tag",attributes,true) 
  .then(function(component) {
  var evt = component.getEvent('componentEvent');
  evt.setParam('entity', entity);  
  evt.fire();
expect(evt.fire()).tobe.(true);
}

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

Dave
  • 5,108
  • 16
  • 30
  • 40
  • Took comments and explanation out of the code block so they would be clearer and easier to find. – Dave Nov 26 '18 at 11:05

0 Answers0