发布

  • fix(vitest): handle zoneless Angular apps in vitest configuration generator (#34700)

    frostbyte_neo 发布于 2026-03-06 11:37:39 +00:00

    Current Behavior

    When running @nx/vitest:configuration on an Angular project, the
    generator always generates import '@analogjs/vitest-angular/setup-zone' regardless of whether the app is
    zoneless. Additionally, the setup file generation logic for Angular 21+
    (which uses setupTestBed()) only exists in
    packages/angular/src/generators/utils/add-vitest.ts
    (createAnalogSetupFile), making the vitest generator not
    self-contained.

    Expected Behavior

    The vitest configuration generator should:

    • Auto-detect whether an Angular project is zoneless (by checking
      polyfills for apps, or zone.js dependency for libraries)
    • Generate setup-snapshots instead of setup-zone for zoneless
      projects
    • Handle Angular 21+ setupTestBed() setup directly, without requiring
      a separate function in the angular package
    • Accept an explicit zoneless option to override auto-detection

    Related Issue(s)

    Fixes #33983

    下载附件