What are the advanced LWC features: NavigationMixin, MessageChannel, Jest testing?
Suggested answer
NavigationMixin: Mix into LWC to navigate programmatically. this[NavigationMixin.Navigate]({ type: 'standard__recordPage', attributes: { recordId, objectApiName, actionName: 'view' } }); Supports record pages, object home, named pages, external URLs. Lightning Message Service (LMS): Publish-subscribe communication between unrelated LWC components (and Aura/VF). Define a Message Channel XML file, import it, and use publish() / subscribe(). Decouples components without parent-child hierarchy requirements. Jest Testing: LWC unit tests use Jest with @salesforce/sfdx-lwc-jest. Key patterns: describe/it/expect structure, createElement for mounting components, registerTestWireAdapter or registerApexTestWireAdapter for mocking wire adapters, jest.mock() for Apex imports. Tests verify DOM output and event dispatch.
Practice content for interview preparation; not an official vendor answer. Verify details against current product documentation.
Community comments (0)
No comments yet.
Sign in or create a free account to add a comment. Comments are moderated before they appear.