Skip to content

Conversation

@rix0rrr
Copy link
Contributor

@rix0rrr rix0rrr commented Nov 28, 2025

(Re-roll of #36226)

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
Copy link
Collaborator

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

Choose a reason for hiding this comment

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

The pull request linter fails with the following errors:

❌ Fixes must contain a change to an integration test file and the resulting snapshot.

If you believe this pull request should receive an exemption, please comment and provide a justification. A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed, add Clarification Request to a comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug This issue is a bug. contribution/core This is a PR that came from AWS. p2

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.

2 participants