greedychipmunk avatar

angularjs-unit-testing

Use this skill for any AngularJS unit testing tasks

by greedychipmunk|Open Source

AngularJS Unit Testing Skill - Completion Report

Status: āœ… COMPLETE
Date: January 10, 2026
Version: 1.2


Executive Summary

A comprehensive, production-ready AngularJS unit testing skill package has been successfully created with complete support for both Jasmine and Jest testing frameworks.

Total Deliverables: 16 files | 6,704 lines of code and documentation


What's Included

šŸ“š Main Documentation

  • skill.md (6,000+ words)
    • Complete skill overview
    • AngularJS component testing guide
    • Jasmine + Jest framework comparison
    • 10+ real-world testing scenarios
    • Debugging strategies and troubleshooting
    • CI/CD integration examples

šŸ“– Resource Guides (7 comprehensive references)

GuideLinesPurpose
AngularJS Testing Reference500+Complete API reference for testing AngularJS components
Testing Patterns Guide600+8+ proven patterns with dual-framework examples
HTTP Mocking Guide504Complete $httpBackend mocking patterns
Mock Helpers & Spies400+Service mocking and spy techniques
Code Coverage Analysis350+Coverage metrics and improvement strategies
Jest Migration Guide400+Comprehensive guide for Jasmine-to-Jest migration
Best Practices Checklist300+Quality assurance checklist with scoring

Total: 3,450+ lines of reference documentation

šŸ“ Test Templates (5 production-ready templates)

TemplateLinesPurpose
controller.spec.js500+Full controller testing (Jasmine + Jest)
service.spec.js600+Full service testing with HTTP mocking
directive.spec.js150+Directive testing template
filter.spec.js100+Filter testing template
fixtures.js400+Reusable test data and helpers

Total: 1,750+ lines of production-ready code

šŸ”§ Automation Scripts

  • run-tests.sh (200+ lines)
    • Automated test execution
    • Coverage report generation
    • Watch mode support
    • CI/CD integration ready

🧭 Navigation

  • INDEX.md - Complete navigation guide
  • README.md (This file)

Framework Support

āœ… Jasmine (Recommended for AngularJS 1.x)

  • Complete API reference
  • Karma integration guide
  • $httpBackend mocking patterns
  • Spy and mock techniques
  • All templates with Jasmine examples

āœ… Jest (Modern alternative)

  • Complete setup guide
  • Jest-specific mocking patterns
  • Migration guide from Jasmine
  • All templates with Jest examples
  • Snapshot testing information

Key Features

Comprehensive Coverage

  • Controllers: Full lifecycle testing, scope management, events
  • Services: HTTP mocking, promises, error handling, caching
  • Directives: DOM manipulation, scope isolation, event handling
  • Filters: Pure function testing with edge cases
  • Promises: Async operations, resolution, rejection handling
  • HTTP: Request mocking, response handling, error scenarios

Production-Ready Code

  • 200+ code examples with real-world scenarios
  • Both Jasmine and Jest implementations
  • Properly commented and documented
  • Best practices integrated throughout
  • Error handling and edge cases covered

Developer Experience

  • Copy-paste ready templates
  • Clear setup instructions
  • Troubleshooting guides
  • Performance tips and tricks
  • Common pitfalls and solutions

File Structure

angularjs-unit-testing-skill/
ā”œā”€ā”€ README.md                              ← You are here
ā”œā”€ā”€ INDEX.md                               ← Navigation guide
ā”œā”€ā”€ skill.md                               ← Main documentation
│
ā”œā”€ā”€ resources/                             ← Reference guides
│   ā”œā”€ā”€ angularjs-testing-reference.md
│   ā”œā”€ā”€ testing-patterns-guide.md
│   ā”œā”€ā”€ http-mocking-guide.md
│   ā”œā”€ā”€ mock-helpers-guide.md
│   ā”œā”€ā”€ coverage-analysis-guide.md
│   ā”œā”€ā”€ jest-migration-guide.md
│   └── best-practices-checklist.md
│
ā”œā”€ā”€ templates/                             ← Copy-paste ready
│   ā”œā”€ā”€ controller.spec.js                 (500+ lines, fully commented)
│   ā”œā”€ā”€ service.spec.js                    (600+ lines, fully commented)
│   ā”œā”€ā”€ directive.spec.js
│   ā”œā”€ā”€ filter.spec.js
│   └── fixtures.js                        (Mock data and helpers)
│
└── scripts/                               ← Automation
    └── run-tests.sh                       (Test runner with coverage)

Quick Start

For Jasmine Users

  1. Read skill.md - Jasmine sections
  2. Copy controller.spec.js template
  3. Reference AngularJS Testing Reference
  4. Follow Best Practices Checklist

For Jest Users

  1. Read Jest Migration Guide
  2. Review Jest setup section in skill.md
  3. Adapt templates from /templates/
  4. Use Jest-specific mocking patterns

For HTTP Testing

  1. Study HTTP Mocking Guide
  2. See real examples in service.spec.js
  3. Use fixtures from fixtures.js

Statistics

MetricValue
Total Files16
Total Lines6,704
Documentation Files8
Test Templates5
Automation Scripts1
Navigation Guides2
Total Words27,500+
Code Examples200+
Test Patterns8+

Feature Matrix

Components Covered

  • āœ… Controllers (initialization, methods, scope, events)
  • āœ… Services (GET, POST, PUT, DELETE, promises)
  • āœ… Directives (compilation, scope, DOM manipulation)
  • āœ… Filters (pure functions, edge cases)
  • āœ… Routes (navigation, parameters)
  • āœ… HTTP (mocking, errors, timeouts)

Test Scenarios

  • āœ… Happy path testing
  • āœ… Error handling and edge cases
  • āœ… Async operations and promises
  • āœ… Scope and event handling
  • āœ… HTTP request/response mocking
  • āœ… Service dependencies and mocking
  • āœ… Performance and coverage

Best Practices Included

  • āœ… AAA Pattern (Arrange-Act-Assert)
  • āœ… Given-When-Then (BDD)
  • āœ… Test fixtures and helpers
  • āœ… Mock and spy techniques
  • āœ… Coverage analysis
  • āœ… CI/CD integration
  • āœ… Debugging strategies

Usage Examples

Running Tests

# Run all tests
./scripts/run-tests.sh

# Watch mode
./scripts/run-tests.sh --watch

# With coverage
./scripts/run-tests.sh --coverage

# Specific browser
./scripts/run-tests.sh --browsers Chrome,Firefox

Using Templates

# Copy controller template
cp templates/controller.spec.js src/components/my-component.spec.js

# Copy service template
cp templates/service.spec.js src/services/my-service.spec.js

# Copy fixtures
cp templates/fixtures.js test/fixtures.js

Referencing Documentation

// When writing tests:
// 1. Check the appropriate template
// 2. Reference AngularJS Testing Reference for API
// 3. Follow Testing Patterns Guide
// 4. Use Best Practices Checklist

Version History

v1.2 (January 10, 2026)

  • āœ… Added Jest migration guide
  • āœ… Expanded mock helpers guide with advanced spying
  • āœ… Created comprehensive coverage analysis guide
  • āœ… Added best practices checklist with scoring
  • āœ… Created INDEX.md navigation guide
  • āœ… Finalized all 16 files

v1.1 (January 8, 2026)

  • āœ… Added Jasmine + Jest dual-framework support
  • āœ… Enhanced all templates with both frameworks
  • āœ… Created testing patterns guide
  • āœ… Created HTTP mocking guide

v1.0 (January 1, 2026)

  • āœ… Initial skill creation
  • āœ… Main documentation with Jasmine focus
  • āœ… Core test templates
  • āœ… Basic fixtures and helpers

Quality Assurance

Documentation Quality

  • āœ… 200+ code examples with explanations
  • āœ… Real-world scenarios and patterns
  • āœ… Both Jasmine and Jest support
  • āœ… Comprehensive table of contents
  • āœ… Clear navigation structure

Code Quality

  • āœ… Production-ready templates
  • āœ… Proper error handling
  • āœ… Extensive comments explaining logic
  • āœ… Best practices integrated
  • āœ… Edge cases covered

Test Coverage

  • āœ… Happy path scenarios
  • āœ… Error scenarios
  • āœ… Edge cases and boundary values
  • āœ… Async operations
  • āœ… Integration scenarios

Support Resources

Internal Resources

External Resources


Next Steps

  1. Review - Start with skill.md
  2. Choose Framework - Jasmine or Jest?
  3. Select Template - Pick appropriate template
  4. Implement Tests - Use templates and guides
  5. Check Quality - Use best practices checklist
  6. Measure Coverage - Run coverage reports

Troubleshooting

Common Issues

IssueSolution
Tests not runningCheck skill.md setup section
HTTP mocking errorsReview HTTP Mocking Guide
Low coverageUse Coverage Analysis Guide
Framework confusionRead Jest Migration Guide

Getting Help

  1. Check relevant resource guide
  2. Review Best Practices Checklist
  3. Examine template examples
  4. Consult troubleshooting sections in skill.md

License & Usage

This skill package is designed to be:

  • āœ… Copied and adapted for your projects
  • āœ… Referenced in documentation
  • āœ… Shared with team members
  • āœ… Integrated into CI/CD pipelines
  • āœ… Extended with custom patterns

Acknowledgments

Created as a comprehensive resource for AngularJS developers learning and implementing unit testing best practices with both Jasmine and Jest frameworks.


Contact & Feedback

For issues, improvements, or feedback on this skill package, refer to the main documentation and resource guides.


AngularJS Unit Testing Skill v1.2
A comprehensive, production-ready guide to testing AngularJS applications with Jasmine and Jest

Created: January 10, 2026
Status: Complete and Ready for Use āœ