Add integration testing utilities#679
Open
crysadrak wants to merge 2 commits into
Open
Conversation
🦋 Changeset detectedLatest commit: d836662 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
db41b2d to
a6a34de
Compare
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add integration testing utilities with
initImaApp,clearImaApp, andsetIntegrationConfigWhat
./integrationexport from@ima/testing-librarywithinitImaApp,clearImaApp,setIntegrationConfig,getIntegrationConfig,aop,unAopAll,hookName, andcreateHook./jest-preset-integration/jest-presetexport — a Jest preset for integration tests that omits theapp/mainmodule name mapper (the integrationinitImaApploads the real app dynamically from a configurableappMainPathinstead)bootImaAppandvalidateJsdomEnvironmenthelpers into a newboot.tsmodule and re-used them in the existing RTLinitImaAppto-aopWhy
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-testinitImaApp.How it works
setIntegrationConfig/getIntegrationConfighold configuration:appMainPath,rootDir,environment,prebootScript,TestPageRenderer, and boot config method overridesinitImaAppdynamically imports the app'smain.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 overridesclearImaApprestores native timers, clears the object container, and callsunAopAlljest-preset-integrationgenerates the jsdom HTML template the same way asjest-preset(viagetIMAResponseContent) but without theapp/mainmoduleNameMapper