Testing application events

The $T global function provides a utility method called $T.fireApplicationEvent to fire an event when testing components that handle the application event.

The code snippet to fire an application event from the testing service is as follows:

$T.fireApplicationEvent(eventName, eventParams)

The following is a sample code snippet that shows how to test a component that handles the application event:

describe('c:componentsubscribingToAppEvent', function () {    it('verify application event', function (done) {        $T.createComponent("c:componentsubscribingToAppEvent")           .then(function (component) {                $T.fireApplicationEvent("c:applicationEvent", {"eventData": "sample event Data"}); expect(component.get("v.eventDataCaptured")).toBe("sample ...

Get Learning Salesforce Lightning Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.