Skip to content

Conversation

@leosvelperez
Copy link
Member

@leosvelperez leosvelperez commented Nov 20, 2025

  • Use Vitest as the default unit test runner for Angular v21
  • Generate Vitest setup using the @angular/build:unit-test builder when using the application executor or the library's ng-packagr executors
  • Add an @nx/angular:unit-test executor to allow providing some extra options and whitelist the usage of relevant Nx executors

@leosvelperez leosvelperez self-assigned this Nov 20, 2025
@leosvelperez leosvelperez requested a review from a team as a code owner November 20, 2025 07:54
@leosvelperez leosvelperez requested review from Coly010 and removed request for a team November 20, 2025 07:54
@vercel
Copy link

vercel bot commented Nov 20, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
nx-dev Ready Ready Preview Nov 21, 2025 4:17pm

@nx-cloud
Copy link
Contributor

nx-cloud bot commented Nov 20, 2025

View your CI Pipeline Execution ↗ for commit 986ea1e

Command Status Duration Result
nx affected --targets=lint,test,test-kt,build,e... ❌ Failed 10m 39s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 2m 55s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 12s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 4s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2025-11-21 17:19:14 UTC

nx-cloud[bot]

This comment was marked as outdated.

@leosvelperez leosvelperez changed the title feat(angular): generate vitest unit test runner by default and use angular builder feat(angular): generate vitest unit test runner by default Nov 21, 2025
Copy link
Contributor

@nx-cloud nx-cloud bot left a comment

Choose a reason for hiding this comment

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

Important

A new CI pipeline execution was requested that may update the conclusion below...

Nx Cloud is proposing a fix for your failed CI:

We added @angular/platform-browser-dynamic as a dependency when configuring Vitest for Angular 21+ projects. This fixes the Cypress component test failures that occurred because Cypress's Angular support requires @angular/platform-browser-dynamic/testing, which was not being installed in the new Vitest configuration path. This change mirrors the approach used in Jest configuration and ensures compatibility with all Angular testing tools.

We could not verify this fix.

diff --git a/packages/angular/src/generators/utils/add-vitest.ts b/packages/angular/src/generators/utils/add-vitest.ts
index 74f681b114..4e63d9f629 100644
--- a/packages/angular/src/generators/utils/add-vitest.ts
+++ b/packages/angular/src/generators/utils/add-vitest.ts
@@ -79,7 +79,11 @@ async function configureAngularUnitTestBuilderTarget(
 
     addDependenciesToPackageJson(
       tree,
-      {},
+      {
+        // @angular/platform-browser-dynamic is required for Cypress component testing
+        // and other testing tools that depend on Angular's dynamic testing utilities
+        '@angular/platform-browser-dynamic': pkgVersions.angularVersion,
+      },
       {
         '@angular/build': angularDevkitVersion,
         jsdom: pkgVersions.jsdomVersion,

Apply fix via Nx Cloud  Reject fix via Nx Cloud


Or Apply changes locally with:

npx nx-cloud apply-locally vLLI-cxL0

Apply fix locally with your editor ↗   View interactive diff ↗


🎓 Learn more about Self-Healing CI on nx.dev

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants