ngt 1.0.29
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet tool install --global ngt --version 1.0.29
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
dotnet tool install --local ngt --version 1.0.29
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=ngt&version=1.0.29
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
nuke :add-package ngt --version 1.0.29
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
ngt - Angular Unit Test Generator
A .NET CLI tool to automatically generate Jest, Vitest, or Jasmine/Karma unit tests for Angular TypeScript files with 80% test coverage target.
Features
- Global .NET Tool - Install once, use anywhere with the
ngtcommand - Runner-Aware - Auto-detects the workspace's test runner (Vitest, Jest, or Jasmine/Karma) and emits the matching mock API (
vi.fn(),jest.fn(), orjasmine.createSpy()) - Smart File Detection - Automatically identifies components, services, guards, interceptors, pipes, directives, and resolvers
- Modern Angular Support - Handles both functional (arrow function) and class-based patterns
- Standalone Components - Detects and properly tests standalone components and directives
- Dependency Detection - Automatically mocks HttpClient, Router, AuthService, and injection tokens
- Non-Destructive - Creates numbered test files when specs already exist (e.g.,
.spec.2.ts) - Workspace Aware - Automatically detects Angular workspaces via
angular.json
Quick Start
Installation
dotnet tool install --global ngt
Usage
Navigate to your Angular project and generate tests:
cd /path/to/angular-app/src/app
ngt generate
Or specify a path:
ngt generate --path /path/to/angular/app
Example Output
Detected Angular workspace at: /home/user/my-angular-app
Generating tests for: /home/user/my-angular-app/src/app
Found 12 TypeScript file(s) to process.
✓ Generated: app.component.spec.ts
✓ Generated: user.service.spec.ts
✓ Generated: auth.guard.spec.ts
✓ Generated: auth.interceptor.spec.ts
✓ Generated: date-format.pipe.spec.ts
- Skipped: user.model (interface/type only)
Test generation complete:
Success: 10
Skipped: 2
Failed: 0
Total: 12
Supported File Types
| Type | File Pattern | Features |
|---|---|---|
| Components | *.component.ts |
TestBed, fixtures, standalone detection |
| Services | *.service.ts |
HTTP mocking, method-level tests |
| Guards | *.guard.ts |
Functional & class-based, auth mocking |
| Interceptors | *.interceptor.ts |
HTTP testing, token injection |
| Pipes | *.pipe.ts |
Transform testing |
| Directives | *.directive.ts |
Host component testing |
| Resolvers | *.resolver.ts |
Route data resolution |
Documentation
- Getting Started - Installation and quick start guide
- User Guide - Complete usage documentation
- Configuration - Configuration options
- Supported Types - Detailed guide for each Angular type
- Examples - Complete source and test examples
- Troubleshooting - Common issues and solutions
- Contributing - How to contribute
Prerequisites
- .NET 9.0 SDK or later
- An Angular application with TypeScript files
Command Reference
Generate Command
ngt generate [options]
| Option | Alias | Description |
|---|---|---|
--path |
-p |
Path to generate tests for (optional) |
--help |
-h |
Show help |
Global Options
ngt --version # Show version
ngt --help # Show help
Configuration
Create appsettings.json in your project to customize behavior:
{
"AngularTestGenerator": {
"TargetCoveragePercentage": 80,
"TestFileExtension": ".spec.ts",
"ExcludedDirectories": ["node_modules", "dist", ".angular", "coverage"]
}
}
See Configuration Guide for all options.
How It Works
- Discovery - Scans the directory for TypeScript files, excluding
node_modules,dist, and existing test files - Analysis - Determines file type, extracts class names, detects dependencies, and identifies patterns (functional vs class-based)
- Generation - Creates appropriate test files with TestBed configuration, mocks, and basic test cases
- Naming - If a test file exists, adds a discriminating number (e.g.,
.spec.2.ts)
Project Structure
src/AngularUnitTests.Cli/
├── Commands/ # CLI command definitions
├── Services/ # Core services (discovery, generation)
├── Models/ # Data models
├── Configuration/ # Options and settings
└── Program.cs # Entry point
Development
Build from Source
git clone https://github.com/QuinntyneBrown/AngularUnitTests.git
cd AngularUnitTests
dotnet build
Run Tests
dotnet test
Install Local Build
dotnet pack src/AngularUnitTests.Cli/AngularUnitTests.Cli.csproj -o ./nupkg
dotnet tool install --global --add-source ./nupkg ngt
Continuous Integration & Publishing
| Workflow | Trigger | What it does |
|---|---|---|
| CI | push / PR to main |
Restores, builds, and tests the solution on Linux, Windows, and macOS |
| Publish to NuGet | push to main / manual |
Builds, tests, packs, and pushes ngt to NuGet with --skip-duplicate |
Publishing pushes the package only when the <Version> in
AngularUnitTests.Cli.csproj
is new, so bump it to cut a release. The workflow requires a NUGET_API_KEY
repository secret.
Contributing
Contributions are welcome! Please read CONTRIBUTING.md and follow our Code of Conduct.
License
MIT — see LICENSE.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.57 | 104 | 7/7/2026 |
| 1.0.51 | 89 | 7/7/2026 |
| 1.0.48 | 102 | 7/6/2026 |
| 1.0.43 | 118 | 6/14/2026 |
| 1.0.42 | 109 | 6/10/2026 |
| 1.0.41 | 102 | 6/10/2026 |
| 1.0.40 | 115 | 6/10/2026 |
| 1.0.34 | 115 | 6/6/2026 |
| 1.0.33 | 114 | 6/5/2026 |
| 1.0.32 | 119 | 6/5/2026 |
| 1.0.30 | 105 | 6/1/2026 |
| 1.0.29 | 105 | 6/1/2026 |
| 1.0.3 | 161 | 2/9/2026 |
| 1.0.2 | 126 | 2/5/2026 |
| 1.0.1 | 129 | 2/5/2026 |
| 1.0.0 | 126 | 2/5/2026 |