LWCIntermediatejestlmstesting
Design Jest test suite for LMS-heavy navigation shell LWC
Real World Scenario
Navigation shell LWC routes LMS messages to ten child regions. Zero Jest tests; routing regression ships breaking three modules.
Expected Answer
• Test matrix: each message type routes to correct handler
• Mock publishMessage assert call count per navigation action
• Snapshot avoided—assert handler side effects on DOM
• Test unknown message type ignored or logged not thrown
• beforeEach fresh MessageContext mock preventing test pollution
• Integration test one golden path multi-step navigation flow
• CI parallel jest per component package in monorepo
Follow-Up Questions & Answers
Click to expand — each follow-up includes a direct, interview-ready answer
Main difference: use case and scale. Test matrix: each message type routes to correct handler. Mock publishMessage assert call count per navigation action. Pick based on your integration pattern and team capability. Message routers are integration hubs—test routing table exhaustively not only happy path. Balance speed of delivery with maintainability.
Architect Perspective
Message routers are integration hubs—test routing table exhaustively not only happy path.