In developing a new Forge application I’ve set about writing JEST unit tests for both the server side code as well as the Custom UI code. I have had success on the server side, mocking out forge api’s as needed. However, I cannot seem to get unit tests in the Custom UI to work.
Specifically Custom UI modules that import @forge/bridge fail as Jest complains that it cannot find the module being imported. This seems related to the bridge module’s package.json declaring its entry point using the keyword ‘browser’ rather than ‘main’. But it likely goes deeper than that.
The lone Custom UI example app I saw that included Jest only did simple comparison testing and did not mock any @forge services and thus avoided the issue.
So I am wondering what is the proper way to unit test Custom UI components with Jest?
The Custom UI examples all show importing @forge modules directly into app components but perhaps a better strategy is to import them in a containing module and pass them in via properties or context?
Any other suggestions?
Best Regards,
Jeff Ryan