Skip to content

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

Merged
mergify[bot] merged 3 commits into
mainfrom
huijbers/jest-cleanup
Nov 28, 2025
Merged

mergify[bot] merged 3 commits into
mainfrom
huijbers/jest-cleanup

Conversation

@rix0rrr

@rix0rrr rix0rrr commented Nov 27, 2025

Copy link
Copy Markdown
Contributor

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.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

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.
@aws-cdk-automation
aws-cdk-automation requested a review from a team November 27, 2025 13:30
@github-actions github-actions Bot added bug This issue is a bug. p2 labels Nov 27, 2025
@mergify mergify Bot added the contribution/core This is a PR that came from AWS. label Nov 27, 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 added the pr-linter/exempt-integ-test The PR linter will not require integ test changes label Nov 27, 2025
@aws-cdk-automation
aws-cdk-automation dismissed their stale review November 27, 2025 14:36

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

@mergify

mergify Bot commented Nov 28, 2025 •

Copy link
Copy Markdown
Contributor

Merge Queue Status Beta

✅ The pull request has been merged

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

Required conditions to merge

@mergify

mergify Bot commented Nov 28, 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 Nov 28, 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 d284733 into main Nov 28, 2025
@mergify
mergify Bot deleted the huijbers/jest-cleanup branch November 28, 2025 12:44
@github-actions

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 Nov 28, 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

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