Introducing The Sweep: OX’s New Live Security Research Series
Register Now
Breaking: The 2026 Vulnpocalypse Hits PHP: Four Critical RCEs, but How Dangerous Are They?
Read the Report
Are you exposed? Connect your apps in minutes.
Scan your apps free

@analogjs/vitest-angular

Latest version: v2.9.8

Overview

Last scanned
23 Nov 2026
Published
23 Nov 2026
npm package Publisher: brandonroberts
3,213 Stars
340 Forks
144 Versions
2.7M Downloads
TypeScript Repo language

Scan summary

@analogjs/vitest-angular was last scanned on 23 Nov 2026 at version 2.9.8. Risk score 0 of 100. No malicious behavior was detected.

  • Releases: 144 versions; the latest 5 were published on 23 Nov 2026.
  • Findings: No rules fired in version 2.9.8.
  • Downloads: 2,651,545 downloads.

Versions

144 versions published
Versions and the rules that fired in each
VersionPublishedStatus
2.9.8 LATEST 23 Nov 2026 No rules fired
3.0.0-beta.59 23 Nov 2026 No rules fired
3.0.0-beta.58 23 Nov 2026 No rules fired
3.0.0-beta.57 23 Nov 2026 Not shown
3.0.0-beta.56 23 Nov 2026 Not shown

No rules fired in 2.9.8

Findings

Findings for v2.9.8. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.

The score describes 2.9.8; other versions have their own rules, not their own score.

README

The publisher’s own README, as collected from the registry.

@analogjs/vitest-angular

A standalone builder for running tests with Vitest and Angular.

Supporting Analog

Installation

Use your package manager of choice to install the necessary packages.

With ng add:

ng add @analogjs/vitest-angular

With npm:

npm install @analogjs/vitest-angular vitest --save-dev

With pnpm:

pnpm install -w @analogjs/vitest-angular vitest --dev

With Yarn:

yarn install @analogjs/vitest-angular vitest --dev

Automated Setup Using a Schematic

A schematic can be used to setup Vitest in an existing Angular project:

Run the schematic to set up the Vite config, test configuration files, and update the test configuration.

npx ng generate @analogjs/vitest-angular:setup --project [your-project-name]
Schematic Options
Option Type Default Description
project string - The name of the project to configure (required)
browserMode boolean false Configure Vitest to run tests in a browser using Playwright

To enable browser mode during setup:

ng g @analogjs/vitest-angular:setup --project [your-project-name] --browserMode

This automatically installs Playwright dependencies and configures Vitest for browser testing. See Setup for Running Tests in the Browser for more details.

If using browser mode, run npx playwright install after the schematic to ensure playwright is installed and configured.

Manual Setup

Vitest can be setup manually also using the steps below.

Setup for Running Tests in Node

To setup Vitest, create a vite.config.mts at the root of your project:

/// <reference types="vitest" />
import { defineConfig } from 'vite';

import angular from '@analogjs/vite-plugin-angular';

export default defineConfig(({ mode }) => ({
  plugins: [angular()],
  test: {
    globals: true,
    setupFiles: ['src/test-setup.ts'],
    environment: 'jsdom',
    include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
    reporters: ['default'],
  },
}));

Next, define a src/test-setup.ts file to setup the TestBed:

Zoneless setup

As of Angular v21, Zoneless change detection is the default for new projects.

Use the following setup:

// src/test-setup.ts
import '@angular/compiler';
import '@analogjs/vitest-angular/setup-snapshots';
import '@analogjs/vitest-angular/setup-serializers';

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

setupTestBed();
Zone.js setup

If you are using Zone.js for change detection, import the setup-zone script before setting up the TestBed. This script patches the test environment for Zone.js helpers such as fakeAsync, and automatically includes support for setting up snapshot tests.

// src/test-setup.ts
import '@angular/compiler';
import '@analogjs/vitest-angular/setup-zone';

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

setupTestBed({
  zoneless: false,
});

The side effect imports must come first. If your formatter sorts side effect imports below named imports, keep them in a separate import group with a blank line, or exclude src/test-setup.ts from import sorting.

Note: With Zone.js, use Vitest's global test functions, with globals: true set in the vite.config.mts, and vitest/globals added to the types array in the tsconfig.spec.json. Importing describe, it, beforeEach, and other functions from vitest directly bypasses the Zone.js patching, and fakeAsync fails with the error Expected to be running in 'ProxyZone', but it was not found. Zoneless tests have no such restriction — when migrating to zoneless change detection, you can switch back to importing the functions from vitest.

Configuration Options

The setupTestBed() function accepts an optional configuration object with the following properties:

  • zoneless (boolean): Whether to use zoneless change detection (default: true)
  • providers (Type<any>[]): Additional providers to include in the test environment (default: [])
  • teardown.destroyAfterEach (boolean): Whether to destroy the test environment after each test. Set to false to keep the component rendered, allowing you to inspect its final state. (default: true)
  • errorOnUnknownElements (boolean): Whether to throw when unknown elements are present in a component's template. Set to false (default) to log the error instead of throwing.
  • errorOnUnknownProperties (boolean): Whether to throw when unknown properties are present in a component's template. Set to false (default) to log the error instead of throwing.

Example with options:

setupTestBed({
  zoneless: true,
  providers: [],
  teardown: { destroyAfterEach: false },
  errorOnUnknownElements: true,
  errorOnUnknownProperties: true,
});

Next, update the test target in the angular.json to use the @analogjs/vitest-angular:test builder:

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "your-project": {
      "projectType": "application",
      "architect": {
        "test": {
          "builder": "@analogjs/vitest-angular:test"
        }
      }
    }
  }
}

Lastly, add the src/test-setup.ts to files array in the tsconfig.spec.json in the root of your project, set the target to es2022, and update the types.

{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "outDir": "./out-tsc/spec",
    "target": "es2022",
    "types": ["vitest/globals", "node"]
  },
  "files": ["src/test-setup.ts"],
  "include": ["src/**/*.spec.ts", "src/**/*.d.ts"]
}

Running Tests

To run unit tests, use the test command:

npm run test
yarn test
pnpm test

The npx vitest command can also be used directly.

Snapshot Testing

For snapshot testing you can use toMatchSnapshot from expect API. The provided snapshot setup also removes Angular-specific _ng* attributes and <!--container--> comments from DOM snapshots, which keeps diffs focused on the actual template output.

The import of setup-snapshots and setup-serializers are complementary:

  • Use setup-snapshots to serialize Angular fixtures and component refs so Vitest snapshots print component markup instead of Angular testing internals.
  • Use setup-serializers to clean DOM snapshots by removing Angular runtime noise such as _ngcontent-*, _nghost-*, ng-reflect-*, generated ids and classes, and removes comments from DOM snapshots (e.g. <!--container-->).

Below is a small example of how to write a snapshot test:

// card.component.spec.ts
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { CardComponent } from './card.component';

describe('CardComponent', () => {
  let fixture: ComponentFixture<CardComponent>;
  let component: CardComponent;

  beforeEach(() =>
    TestBed.configureTestingModule({
      imports: [CardComponent],
    }),
  );

  beforeEach(() => {
    fixture = TestBed.createComponent(CardComponent);
    component = fixture.componentInstance;
    fixture.detectChanges();
  });

  it('should create the app', () => {
    expect(fixture).toMatchSnapshot();
  });
});

After you run the test, a card.component.spec.ts.snap file is created in the__snapshots__ folder with the below content:

// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`CardComponent > should create the app 1`] = `
  <component-code>
`;

The snapshots generated should be reviewed and added to version control.

Using TypeScript Config Path Aliases

If you are using paths in your tsconfig.json, support for those aliases can be added to the vite.config.ts.

First, install the vite-tsconfig-paths package.

With npm:

npm install vite-tsconfig-paths --save-dev

With pnpm:

pnpm install -w vite-tsconfig-paths --dev

With Yarn:

yarn add vite-tsconfig-paths --dev

Next, add the plugin to the plugins array in the vite.config.ts.

/// <reference types="vitest" />
import { defineConfig } from 'vite';

import angular from '@analogjs/vite-plugin-angular';
import viteTsConfigPaths from 'vite-tsconfig-paths';

export default defineConfig(({ mode }) => ({
  // ...other config
  plugins: [angular(), viteTsConfigPaths()],
}));
With Nx

Nx workspaces use the same vite-tsconfig-paths plugin. The nxViteTsPaths plugin from @nx/vite is deprecated and is removed in Nx 24, so replace it with viteTsConfigPaths().

IDE Support

Tests can also be run directly from your IDE using the Vitest IDE integrations for VS Code or JetBrains IDEs.

OX Radar and Response Center

Find threats in your stack.

OX Radar can check high-priority threats, like critical package CVEs, against your context.

Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.

Where it’s listed

The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).

  • npm @analogjs/vitest-angular

References

The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.

Scan your whole stack

Group 1261154050 1
Group 1261154050
 

From OX Research Newsroom

Microsoft's Official agent framework Hijacked
AI & VibeSec

BREAKING: Hijacked Releases of Microsoft’s Official agent-framework Steals Azure and CI Credentials

Copy of Template Design OX Blog (1)
Research

Thousands Of GitHub Accounts Hijacked With wfx-loot CI Secret Stealing Malware Via GitHub Actions & npm

Copy of Template Design OX Blog (2)
Research

NGINX2Root: Five Critical NGINX Flaws Expose Web Servers to Remote Code Execution

Frame 2085668439 (1)
Group 1261154229