The `office-addin-test-helpers` package provides essential utilities for automating the validation and testing of Office Add-ins. Part of the broader `Office-Addin-Scripts` monorepo maintained by Microsoft OfficeDev, this library offers programmatic access to functionalities like manifest verification, add-in registration, sideloading, and communication with a test server. It is commonly used in conjunction with the `office-addin-test-server` package and popular testing frameworks such as Mocha or Jest to facilitate integration and end-to-end testing of add-ins across various Office applications (Excel, Word, Outlook, etc.). The current stable version is 2.0.4. While the monorepo has different release cadences for its constituent packages, `office-addin-test-helpers` generally follows a steady update schedule, ensuring compatibility with the evolving Office Add-ins platform.
npm install office-addin-test-helpersVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `office-addin-test-helpers` to programmatically verify an add-in manifest, initiate add-in sideloading, and send simulated test results to a test server. It highlights the typical workflow for automating Office Add-in testing.
Review the package's changelog or the `Office-Addin-Scripts` repository's documentation for specific migration instructions for your version upgrade.
For unit testing client-side code that interacts with Office APIs, use the `office-addin-mock` library to create mock Office objects. This allows tests to run without an active Office application.
Implement a `finally` block or a teardown script in your test runner to explicitly call the unregistration functions, or ensure `npm run stop` is executed after each test run.
Regularly clear the Office cache during development. For Windows, this typically involves deleting the contents of `%LOCALAPPDATA%\Microsoft\Office\16.0\Wef\` or using the `office-addin-dev-certs uninstall` and `install` commands. For other platforms, refer to Microsoft's official documentation on clearing the Office cache.
Unit test Office API interactions using `office-addin-mock`. For integration/end-to-end tests, ensure the code runs within an actual Office Add-in task pane or content pane loaded by an Office application.
Examine the error messages returned by `verifyManifestFile` carefully. Use a manifest validator or schema definitions (like the Office Add-in XML Schema) to correct errors in the manifest file.
Ensure `office-addin-test-server` is started and running on the correct port before executing tests that require server communication. Verify firewall rules are not blocking the connection.