Skip to content

fix(core): temp cleanup does not work with jest - #36238

Merged
mergify[bot] merged 7 commits into
mainfrom
huijbers/jest-cleanup2
Dec 1, 2025
Merged

mergify[bot] merged 7 commits into
mainfrom
huijbers/jest-cleanup2

Conversation

@rix0rrr

@rix0rrr rix0rrr commented Nov 28, 2025 •

Copy link
Copy Markdown
Contributor

Re-roll of #36226. The previous version had to be reverted because it was causing ENOMEM errors on the build server. In this one, raise the per-process memory requirements from 4GB -> 6GB, so that we run fewer tests in parallel. In the test pipeline this makes the build pass.

Our temporary cleanup fix submitted in #36043 doesn't work for tests run with jest, because jest suppresses the standard Node exit event, causing the cleanup to never run.

Instead, we introduce a new public static function which people using jest can call:

afterAll(CloudAssembly.cleanupTemporaryDirectories);

As well as a convenience script to automatically inject this handler into all jest tests:

$ jest --setupFilesAfterEnv aws-cdk-lib/testhelpers/jest-autoclean

Once this PR has been merged and released we will add the above to all CLI init templates.

Closes #802, hopefully for good.

Our temporary cleanup fix submitted in #36043 doesn't work for tests run with `jest`, because `jest` suppresses the standard Node `exit` event, causing the cleanup to never run.

Instead, we introduce a new public static function which people using `jest` can call:

```ts
afterAll(CloudAssembly.cleanupTemporaryDirectories);
```

As well as a convenience script to automatically inject this handler into all jest tests:

```
$ jest --setupFilesAfterEnv aws-cdk-lib/testhelpers/jest-autoclean
```

Once this PR has been merged and released we will add the above to all CLI init templates.

Closes #802, hopefully for good.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@rix0rrr
rix0rrr marked this pull request as draft November 28, 2025 15:10
@aws-cdk-automation
aws-cdk-automation requested a review from a team November 28, 2025 15:10
@github-actions github-actions Bot added bug This issue is a bug. p2 labels Nov 28, 2025
@mergify mergify Bot added the contribution/core This is a PR that came from AWS. label Nov 28, 2025

@aws-cdk-automation aws-cdk-automation left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(This review is outdated)

@rix0rrr
rix0rrr force-pushed the huijbers/jest-cleanup2 branch from ed9f4ac to dcbcb24 Compare December 1, 2025 10:25
@rix0rrr
rix0rrr marked this pull request as ready for review December 1, 2025 12:35
@rix0rrr rix0rrr added pr-linter/exempt-test The PR linter will not require test changes pr-linter/exempt-integ-test The PR linter will not require integ test changes labels Dec 1, 2025
@aws-cdk-automation
aws-cdk-automation dismissed their stale review December 1, 2025 12:37

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Dec 1, 2025
Comment thread build.sh Resolved
@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Dec 1, 2025
Co-authored-by: A. Abdel-Rahman <[email protected]>
@mergify

mergify Bot commented Dec 1, 2025 •

Copy link
Copy Markdown
Contributor

Merge Queue Status Beta

✅ The pull request has been merged

This pull request spent 28 minutes 30 seconds in the queue, including 28 minutes 20 seconds waiting for CI.
The checks were run in-place.

Required conditions to merge

@mergify

mergify Bot commented Dec 1, 2025

Copy link
Copy Markdown
Contributor

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify

mergify Bot commented Dec 1, 2025

Copy link
Copy Markdown
Contributor

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify
mergify Bot merged commit 1f4a224 into main Dec 1, 2025
@mergify
mergify Bot deleted the huijbers/jest-cleanup2 branch December 1, 2025 16:21
@github-actions

github-actions Bot commented Dec 1, 2025

Copy link
Copy Markdown
Contributor

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Dec 1, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bug This issue is a bug. contribution/core This is a PR that came from AWS. p2 pr-linter/exempt-integ-test The PR linter will not require integ test changes pr-linter/exempt-test The PR linter will not require test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.NET generation needs to use full type names for reused names cross-construct.

3 participants