Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>Angular Smart Test GeneratorNew to Visual Studio Code? Get it now.
Angular Smart Test Generator

Angular Smart Test Generator

B Aravind

|
4 installs
| (0) | Free
Automatically generate comprehensive unit tests for Angular components, services, pipes, directives, and guards
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Angular Smart Test Generator

A powerful VS Code extension that automatically generates comprehensive unit tests for Angular components, services, pipes, directives, and guards with zero configuration.

Features

  • Automatic Test Generation: Generate complete, runnable tests with a single click or keyboard shortcut
  • Framework Auto-Detection: Automatically detects whether your project uses Jasmine or Jest
  • Comprehensive Coverage: Supports all Angular element types:
    • Components (with template binding tests)
    • Services (with HTTP testing support)
    • Pipes (with edge case testing)
    • Directives (with host listener/binding tests)
    • Guards (with route protection tests)
  • Smart Analysis: Uses TypeScript AST parsing for accurate code analysis
  • Intelligent Mocking: Auto-generates mocks for all dependencies
  • Multiple Activation Methods:
    • Right-click context menu on TypeScript files
    • Command Palette (Generate Tests)
    • Keyboard shortcut (Ctrl+Shift+T / Cmd+Shift+T)

Installation

  1. Open VS Code
  2. Press Ctrl+P / Cmd+P to open Quick Open
  3. Type ext install ng-smart-test-gen
  4. Press Enter

Usage

Method 1: Context Menu (Recommended)

  1. Right-click any Angular TypeScript file (component, service, pipe, etc.)
  2. Select "Generate Tests" from the context menu
  3. Test file is created/updated automatically

Method 2: Keyboard Shortcut

  1. Open any Angular TypeScript file
  2. Press Ctrl+Shift+T (Windows/Linux) or Cmd+Shift+T (Mac)
  3. Test file is created/updated automatically

Method 3: Command Palette

  1. Open any Angular TypeScript file
  2. Press Ctrl+Shift+P / Cmd+Shift+P
  3. Type "Generate Tests" and press Enter

What Gets Generated

For Components:

  • Basic component creation test
  • Lifecycle hook tests
  • Method tests with parameter handling
  • @Input property tests
  • @Output event emitter tests
  • Template binding tests (click, property bindings, etc.)
  • Proper TestBed configuration
  • Mock setup for all dependencies

For Services:

  • Service creation test
  • Method tests (sync, async, Observable, Promise)
  • HTTP testing setup (if HttpClient is used)
  • Mock dependency setup
  • Error handling scenarios

For Pipes:

  • Pipe creation test
  • Transform method tests
  • Edge case tests (null, undefined, empty values)
  • Multiple parameter handling

For Directives:

  • Directive creation test
  • Host listener tests
  • Host binding tests
  • Test host component setup
  • Method tests

For Guards:

  • Guard creation test
  • Route activation/deactivation tests
  • Allow and deny scenarios
  • Mock route/state setup

Configuration

No configuration needed! The extension automatically:

  • Detects your testing framework (Jasmine or Jest)
  • Analyzes your project structure
  • Identifies Angular element types
  • Generates appropriate tests

Requirements

  • VS Code 1.85.0 or higher
  • Angular project with TypeScript
  • Testing framework (Jasmine or Jest)

Known Limitations

  • Inline templates are not yet fully supported for binding extraction
  • Complex template expressions may need manual adjustment
  • Custom decorators require manual test updates

Extension Settings

This extension contributes the following commands:

  • ng-smart-test-gen.generateTests: Generate tests for the current Angular file

Tips

  1. Review Generated Tests: Always review and customize generated tests for your specific business logic
  2. Mock Return Values: Adjust mock return values to match your application's data structures
  3. Add Edge Cases: Supplement generated tests with additional edge cases specific to your requirements
  4. Keep Tests Updated: Re-run generation when you modify your source files (append mode available)

Roadmap

  • [ ] Support for inline template analysis
  • [ ] Custom test template configuration
  • [ ] Batch test generation for multiple files
  • [ ] Integration test generation
  • [ ] E2E test generation
  • [ ] Code coverage reporting integration

Contributing

Found a bug or have a feature request? Please open an issue at: https://github.com/Mechagodz-glitch/ng-smart-test-gen/issues

Release Notes

See CHANGELOG.md for detailed release notes.

License

This extension is licensed under the MIT License.


Enjoy automated testing! 🚀

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft