{"library":"office-addin-test-helpers","title":"Office Add-in Test Helpers","description":"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.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install office-addin-test-helpers"],"cli":null},"imports":["import { verifyManifestFile } from 'office-addin-test-helpers';","import { sideloadAddin } from 'office-addin-test-helpers';","import { sendTestResults } from 'office-addin-test-helpers';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { verifyManifestFile, sideloadAddin, AppType, sendTestResults } from 'office-addin-test-helpers';\nimport * as path from 'path';\n\n// Assuming a manifest file exists at this path\nconst manifestPath = path.resolve(__dirname, './test-manifest.xml');\n\nasync function runTestScenario() {\n  console.log('Starting Office Add-in test scenario...');\n\n  try {\n    // 1. Verify the add-in manifest file\n    console.log('Verifying manifest file...');\n    const manifestValidationResult = await verifyManifestFile(manifestPath);\n    if (!manifestValidationResult.succeeded) {\n      throw new Error(`Manifest verification failed: ${manifestValidationResult.errors.join(', ')}`);\n    }\n    console.log('Manifest file verified successfully.');\n\n    // 2. Sideload the add-in (example for Excel)\n    console.log('Sideloading add-in...');\n    // Note: In a real scenario, you would start office-addin-test-server beforehand\n    // and provide actual Office host application to interact with.\n    // The sideloadAddin function typically requires an Office instance to attach to.\n    // This example simulates the call without actual Office interaction.\n    await sideloadAddin(manifestPath, AppType.Excel);\n    console.log('Add-in sideload command initiated (requires actual Office host).');\n\n    // 3. Simulate sending test results to a test server (e.g., office-addin-test-server)\n    console.log('Simulating sending test results...');\n    const testServerPort = 4201; // Default port for office-addin-test-server\n    const results = {\n      status: 'passed',\n      testName: 'Basic Add-in Functionality',\n      message: 'Add-in loaded and performed a basic operation.'\n    };\n    await sendTestResults(testServerPort, JSON.stringify(results));\n    console.log('Test results sent to test server:', results);\n\n    console.log('Office Add-in test scenario completed successfully.');\n  } catch (error) {\n    console.error('Error during Office Add-in test scenario:', error);\n    // In a real test, you would mark the test as failed here.\n    process.exit(1);\n  }\n}\n\nrunTestScenario();","lang":"typescript","description":"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}