Skip to content

Angular vitest setup does include setup-zone for zoneless applications #33983

@JelleBruisten

Description

@JelleBruisten

Current Behavior

I've added configuration for vitest by using @nx/vitest:configuration, and it does work and generate the test-setup.ts correctly however:

import '@angular/compiler';
import '@analogjs/vitest-angular/setup-zone';

import {
  BrowserTestingModule,
  platformBrowserTesting,
} from '@angular/platform-browser/testing';
import { getTestBed } from '@angular/core/testing';

getTestBed().initTestEnvironment(
  BrowserTestingModule,
  platformBrowserTesting()
);

Every library/Application in this workspace is zoneless therefore zonejs is not in our package.json etc.

https://analogjs.org/docs/features/testing/vitest
Says we should use:

import '@angular/compiler';
import '@analogjs/vitest-angular/setup-snapshots';
import { setupTestBed } from '@analogjs/vitest-angular/setup-testbed';

setupTestBed();

Should the configuration generator ask or have an option to say if its zoneless?

Expected Behavior

Test configuration would be setup with zoneless

GitHub Repo

No response

Steps to Reproduce

run on an project without a test target: @nx/vitest:configuration

Nx Report

NX   Report complete - copy this into the issue template

Node           : 22.14.0
OS             : win32-x64
Native Target  : x86_64-windows
yarn           : 4.9.4

nx (global)            : 22.0.2
nx                     : 22.3.3
@nx/js                 : 22.3.3
@nx/eslint             : 22.3.3
@nx/workspace          : 22.3.3
@nx/angular            : 22.3.3
@nx/jest               : 22.3.3
@nx/cypress            : 22.3.3
@nx/devkit             : 22.3.3
@nx/eslint-plugin      : 22.3.3
@nx/module-federation  : 22.3.3
@nx/node               : 22.3.3
@nx/plugin             : 22.3.3
@nx/rspack             : 22.3.3
@nx/vite               : 22.3.3
@nx/vitest             : 22.3.3
@nx/web                : 22.3.3
@nx/webpack            : 22.3.3
@nx/docker             : 22.3.3
typescript             : 5.9.3

---------------------------------------
Nx key licensed packages

@nx/azure-cache            : 5.0.0
@nx/powerpack-azure-cache  : 5.0.0

---------------------------------------
Community plugins:
@alyle/ui                     : 19.0.0
@analogjs/vite-plugin-angular : 2.2.0
@analogjs/vitest-angular      : 2.2.0
@jsverse/transloco            : 7.6.1
@ngrx/component-store         : 21.0.1
@ngrx/eslint-plugin           : 21.0.1
@ngrx/operators               : 21.0.1
@ngrx/schematics              : 21.0.1
@ngrx/signals                 : 21.0.1
@nx/azure-cache               : 5.0.0
angular-eslint                : 21.1.0

Failure Logs

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

Metadata

Metadata

Assignees

Labels

scope: angularIssues related to Angular support in Nxscope: testing toolsIssues related to Cypress / Jest / Playwright / Vitest support in Nxtype: bug

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions