Skip to main content
This guide covers how to test your SofIA SDK integration, from verifying basic setup to automating tests in CI/CD pipelines.

Testing strategy overview

Manual verification checklist

Before writing automated tests, verify the basics with debug="true":
1

Component renders

Open your page and confirm the SofIA widget appears. Check the console for [Sofia SDK] Configuration Error — if absent, props are valid.
2

Template loads

Look for [Sofia SDK] Settings - Template loaded: {n} fields in the console. If n matches your expected field count, the template parsed correctly.
3

Generate button appears

If both template and templateid are set, the generate button should be visible. If missing, check template validation logs.
4

handleReport fires

Click Generate after a conversation and verify your handleReport callback receives data. Log the output with JSON.stringify(report, null, 2).

Unit testing callbacks

Test your callback functions independently from the SDK. These tests verify that your application correctly processes the data SofIA delivers.

Testing handleReport

Testing template validation

Integration testing

Testing component mounting (Vanilla JS)

Testing with React

Testing with Angular

Mocking the SDK for CI/CD

In CI environments where the SDK cannot connect to real servers, mock the web component to test your integration logic:
Using the mock in tests:

Testing report delivery

SofIA delivers data through callback properties, not DOM events. Reports arrive by the SDK calling the handleReport property you assign (sofia.handleReport = fn) — the SDK does not emit handle-report/set-is-open/set-get-last-report DOM events. Test the callback path, not addEventListener.
Assign your callback as a property and assert it receives the report:
The only DOM CustomEvent the SDK actually emits is sofia:transcriber-url-changed (with detail: { url }), fired when the transcriber URL is resolved. You rarely need it, but it can be observed with a standard addEventListener('sofia:transcriber-url-changed', ...).

Test environment configuration

Vitest configuration

Setup file

Focus your automated tests on your integration code (callbacks, data transformations, UI updates), not on the SDK internals. The SDK is tested internally with 160+ test cases. Your tests should verify that your application correctly processes the data SofIA delivers.

Next steps

  1. Troubleshooting — solutions for common issues
  2. Error Reference — complete catalog of SDK error messages
  3. Migration Guide — upgrade from v0.x to v1.0