fix(test): add moduleNameMapper for @smithy/core subpath exports#1167
Open
davidhessler wants to merge 2 commits into
Open
fix(test): add moduleNameMapper for @smithy/core subpath exports#1167davidhessler wants to merge 2 commits into
davidhessler wants to merge 2 commits into
Conversation
Upgrades project dependencies. See details in [workflow run]. [Workflow Run]: https://github.com/cdklabs/cdk-ecs-codedeploy/actions/runs/26414586495 ------ *Automatically created by projen via the "upgrade-main" workflow* Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@aws-sdk/client-codedeploy@3.1053.0 pulls in @smithy/core@3.24.3 which uses self-referencing subpath exports (e.g. @smithy/core/protocols requires @smithy/core/schema). Jest's module resolver does not properly handle these self-references with ts-jest/CommonJS, causing schema.TypeRegistry to be undefined in the HttpProtocol constructor. Add moduleNameMapper entries for @smithy/core/* and @aws-sdk/core/* subpath exports to resolve them directly to their CJS entry points. This fixes all 39 test failures introduced by the dependency upgrade.
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.
Problem
The dependency upgrade in #1166 (
@aws-sdk/client-codedeploy3.1045.0 → 3.1053.0) pulls in@smithy/core@3.24.3which uses self-referencing subpath exports. For example,@smithy/core/protocolsrequires@smithy/core/schemainternally.Jest's module resolver (with ts-jest/CommonJS) does not properly handle these self-referencing package exports, causing
schema.TypeRegistryto beundefinedwhen theHttpProtocolconstructor runs:This breaks all tests that instantiate
CodeDeployClient(19 of 39 tests fail).Fix
Add
moduleNameMapperentries in.projenrc.ts→jestOptions.jestConfigto explicitly resolve@smithy/core/*and@aws-sdk/core/*subpath imports to their CJS entry points:Verification
All 39 tests pass after this change. This unblocks #1166.
Related
aws-sdk-client-mockv4.1.0 doesn't yet handle the new protocol-based client architecture in@smithy/core3.24.x