Skip to content

fix(@schematics/angular): preserve nested done callbacks during Vitest migration - #34787

Open
nagahara-naoki wants to merge 1 commit into
angular:mainfrom
nagahara-naoki:codex/34730-nested-done
Open

nagahara-naoki wants to merge 1 commit into
angular:mainfrom
nagahara-naoki:codex/34730-nested-done

Conversation

@nagahara-naoki

Copy link
Copy Markdown
Contributor

PR Checklist

  • The commit message follows the contribution guidelines.
  • Tests cover the change.

PR Type

  • Bugfix

What is the current behavior?

The Jasmine-to-Vitest migration can remove a nested done() from a timer or subscription and mark the spec as async. 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 to await when 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?

  • No

Testing

Ran pnpm bazel test //packages/schematics/angular:test --nocache_test_results locally. The suite reported 989 passing specs and one previously disabled spec. Coverage includes timers, custom callback names, nested done.fail(), and a subscription combined with .then(done) through the schematic entry point.

…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

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor-jasmine-vitest removes done() from asynchronous callbacks, so migrated tests no longer wait for them

1 participant