Repository navigation
fix(@schematics/angular): preserve nested done callbacks during Vitest migration - #34787
Open
nagahara-naoki wants to merge 1 commit into
Open
nagahara-naoki wants to merge 1 commit into
nagahara-naoki wants to merge 1 commit into
Conversation
…t migration Keep Jasmine completion callbacks in nested functions when the migration cannot await their work. Flag the test for manual migration and report only transformations that were applied. Fixes angular#34730
There was a problem hiding this comment.
Code Review
This pull request refactors the Jasmine-to-Vitest schematic transformer to prevent incorrect automatic migration of nested done callbacks (such as those inside setTimeout or other nested functions). Instead of attempting to transform them to async/await, these nested usages are now correctly flagged for manual migration with a TODO comment, and the done parameter is preserved. The internal tracking of handled transformations in jasmine-lifecycle.ts was also updated to collect transformation messages and report them only when the migration succeeds. There are no review comments to address, so I have no feedback to provide.
1 task
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.
PR Checklist
PR Type
What is the current behavior?
The Jasmine-to-Vitest migration can remove a nested
done()from a timer or subscription and mark the spec asasync. The migrated spec can finish before the callback runs, even if the expected event never arrives.Fixes #34730
What is the new behavior?
If a completion callback occurs inside a function whose work the migration cannot await, the schematic preserves the callback and adds the existing manual-migration TODO. Supported promise patterns such as
promise.then(done)still migrate toawaitwhen all uses can be handled.If a test mixes supported and unsupported uses, the verbose log reports that manual migration is required and only lists edits actually applied.
Does this PR introduce a breaking change?
Testing
Ran
pnpm bazel test //packages/schematics/angular:test --nocache_test_resultslocally. The suite reported 989 passing specs and one previously disabled spec. Coverage includes timers, custom callback names, nesteddone.fail(), and a subscription combined with.then(done)through the schematic entry point.