Skip to content

Add integration testing utilities#679

Open
crysadrak wants to merge 2 commits into
masterfrom
cnsqa-1710
Open

Add integration testing utilities#679
crysadrak wants to merge 2 commits into
masterfrom
cnsqa-1710

Conversation

@crysadrak
Copy link
Copy Markdown
Collaborator

Add integration testing utilities with initImaApp, clearImaApp, and setIntegrationConfig

What

  • Added a new ./integration export from @ima/testing-library with initImaApp, clearImaApp, setIntegrationConfig, getIntegrationConfig, aop, unAopAll, hookName, and createHook
  • Added ./jest-preset-integration/jest-preset export — a Jest preset for integration tests that omits the app/main module name mapper (the integration initImaApp loads the real app dynamically from a configurable appMainPath instead)
  • Extracted shared bootImaApp and validateJsdomEnvironment helpers into a new boot.ts module and re-used them in the existing RTL initImaApp
  • Added ambient type declaration for to-aop

Why

Integration tests need to boot the real IMA application (loaded dynamically from a configurable path) instead of a mocked app/main, run with a live router, wrap global timers for cleanup, and support per-suite boot config overrides — capabilities not covered by the existing unit-test initImaApp.

How it works

  • setIntegrationConfig / getIntegrationConfig hold configuration: appMainPath, rootDir, environment, prebootScript, TestPageRenderer, and boot config method overrides
  • initImaApp dynamically imports the app's main.js, wraps global timers (so they can be cleared after each test), calls $Router.listen() so IMA's route handler is active in jsdom, and merges boot config methods from both the default app functions and the per-suite overrides
  • clearImaApp restores native timers, clears the object container, and calls unAopAll
  • jest-preset-integration generates the jsdom HTML template the same way as jest-preset (via getIMAResponseContent) but without the app/main moduleNameMapper

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 24, 2026

🦋 Changeset detected

Latest commit: d836662

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@ima/testing-library Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@crysadrak crysadrak force-pushed the cnsqa-1710 branch 2 times, most recently from db41b2d to a6a34de Compare May 7, 2026 12:03
…nd `setIntegrationConfig`

Co-authored-by: Copilot <copilot@github.com>
- Changed the import path for testing integration from '@ima/plugin-testing-integration' to '@ima/testing-library/integration'.
- Enhanced the createIMAServer function to accept an explicit environmentName parameter.
- Added tests to ensure environment resolution occurs at the factory call rather than module load.
- Refactored environmentFactory to resolve environment names more cleanly and added support for explicit environment overrides.
- Updated TypeScript definitions to include environmentName in server configuration.
- Modified testing library to allow setting a specific environment for jsdom HTML template generation.
- Introduced new tests for booting the IMA app and integration app initialization to validate environment propagation and error handling.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant