diff --git a/packages/angular/cli/src/commands/mcp/tools/onpush-zoneless-migration/prompts.ts b/packages/angular/cli/src/commands/mcp/tools/onpush-zoneless-migration/prompts.ts index 7176808e6a28..01254ed5fc61 100644 --- a/packages/angular/cli/src/commands/mcp/tools/onpush-zoneless-migration/prompts.ts +++ b/packages/angular/cli/src/commands/mcp/tools/onpush-zoneless-migration/prompts.ts @@ -25,8 +25,12 @@ export function createProvideZonelessForTestsSetupPrompt(testFilePath: string): In the main \`beforeEach\` block for the test suite (the one inside the top-level \`describe\`), add \`provideZonelessChangeDetection()\` to the providers array in \`TestBed.configureTestingModule\`. + * If there is already an import from \`@angular/core\`, add \`provideZonelessChangeDetection\` to the existing import. + * Otherwise, add a new import statement for \`provideZonelessChangeDetection\` from \`@angular/core\`. + \`\`\`diff - + import { provideZonelessChangeDetection } from '@angular/core'; + - import {{ SomeImport }} from '@angular/core'; + + import {{ SomeImport, provideZonelessChangeDetection }} from '@angular/core'; describe('MyComponent', () => { + beforeEach(() => { @@ -202,6 +206,9 @@ export async function createFixResponseForZoneTests( The following usages of \`provideZoneChangeDetection\` must be removed: ${locations.map((loc) => `- ${loc}`).join('\n')} + + After removing \`provideZoneChangeDetection\`, the tests will likely fail. Use this guide to diagnose and fix the failures. + ${testDebuggingGuideText(sourceFile.fileName)} ### Final Step @@ -214,8 +221,6 @@ function testDebuggingGuideText(fileName: string) { return ` ### Test Debugging Guide - After removing \`provideZoneChangeDetection\`, the tests will likely fail. Use this guide to diagnose and fix the failures. - 1. **\`ExpressionChangedAfterItHasBeenCheckedError\`**: * **Cause**: This error indicates that a value in a component's template was updated, but Angular was not notified to run change detection. * **Solution**: