Search code examples
office365office-jsoffice365-apps

How do you unit test office.js app code?


Are there any common practices, frameworks or patterns for unit testing office.js based code? Given the large number of the components in thr object model, it's impossible to mock calls to office.js. Is there something like a karma launcher to launch test code in to a test container task pane app? Anybody has worked out an effective way to test code that interact with office.js?


Solution

  • Here's what I ended up doing:

    1. Added a new Task Pane App project to the solution
    2. Included the Jasmine Standalone zip from https://github.com/jasmine/jasmine/releases
    3. Made TaskPane app's Manifest Source Location point to the SpecRunner.html
    4. Modified boot.js to replace the execution of test specs on window.load to execute on Office.initilize.