Testing Miniapps
Test business logic through small typed ports and reserve host-backed tests for a real miniapp realm. This keeps unit tests deterministic without copying a private transport.
Inject the Capability You Use
Importing the live sdk object is safe, but reading one of its properties without a host capability session throws. Keeping host access at the surface boundary makes business logic easier to test and prevents accidental property access during test setup.
Define a narrow application port:
Pass the live capability at the surface boundary and a plain test double in unit tests:
Surface Context Doubles
Create a complete TapFederatedSurfaceMountContext with inert event and authority implementations. Override only the scope field needed by a test.
Test both authority states, missing optional scope, repeated unmount, event unsubscribe, rejected SDK operations, and work settling after unmount.
Theme Helpers
Pass an explicit query string to getMiniAppThemeFromSearch and a spy callback to installMiniAppThemeSync. Always call the returned cleanup function and verify later events have no effect.
Package Tests
Your package CI should:
- install dependencies from the public npm registry in a clean checkout;
- typecheck and run the complete unit suite;
- build every declared target;
- assemble and scan the complete package;
- validate the emitted descriptor against
config-schema.json; - import every declared expose from its emitted graph; and
- verify that target and contribution IDs match the source descriptor.
Add a clean consumer test that installs the packed or published SDK without local links or repository-specific configuration.
Host Acceptance
Before pinning the production environment, test the immutable release in The AI Platform through its development environment. Cover initial activation, an update to a new release, compatible state restoration, rollback, and a deliberately failing candidate that leaves the last known good release active.