Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"build:watch": "npm run build:watch --workspaces --if-present",
"clean": "npm run clean --workspaces --if-present && rimraf node_modules",
"test": "npm run test --workspaces --if-present -- --testPathIgnorePatterns=/integration/",
"test:coverage": "jest --config=tests/jest.config.json --coverage",
Comment thread
mrunalhirve128 marked this conversation as resolved.
Outdated
"test:watch": "npm run test:watch --workspaces --if-present",
"test:integration": "jest --config jest.integration.config.cjs",
"test:integration:watch": "jest --config jest.integration.config.cjs --watch",
Expand Down
27 changes: 27 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Microsoft Agent 365 SDK Tests

Unit and integration tests for the Microsoft Agent 365 SDK - Node.js/TypeScript. This test suite ensures reliability, maintainability, and quality across all modules including runtime, tooling, notifications, and observability extensions.

## Usage

For detailed instructions on running tests and generating coverage reports, see:

- **[Test Plan](TEST_PLAN.md)** - Comprehensive testing strategy and implementation roadmap
- **[Running Tests](RUNNING_TESTS.md)** - Complete guide for installation, running tests, generating coverage reports, and troubleshooting

## Support

For issues, questions, or feedback:

- File issues in the [GitHub Issues](https://github.com/microsoft/Agent365-nodejs/issues) section
- See the [main documentation](../README.md) for more information

## Trademarks

*Microsoft, Windows, Microsoft Azure and/or other Microsoft products and services referenced in the documentation may be either trademarks or registered trademarks of Microsoft in the United States and/or other countries. The licenses for this project do not grant you rights to use any Microsoft names, logos, or trademarks. Microsoft's general trademark guidelines can be found at <http://go.microsoft.com/fwlink/?LinkID=254653>.*

## License

Copyright (c) Microsoft Corporation. All rights reserved.

Licensed under the MIT License - see the [LICENSE](../LICENSE.md) file for details.
112 changes: 112 additions & 0 deletions tests/RUNNING_TESTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# Running Unit Tests for Agent365-nodejs SDK

---

## Prerequisites

1. **Node.js 18+**: `node --version`
2. **pnpm**: `npm install -g pnpm`
3. **Dependencies**: `pnpm install` (from repository root)
4. **Build packages**: `pnpm build` (required before running tests)

---

## Test Structure

```plaintext
tests/
├── runtime/ # Runtime tests
├── observability/ # Observability tests
├── tooling/ # Tooling tests
└── notifications/ # Notifications tests
```

---

## Running Tests

### Command Line

```powershell
# From repository root
pnpm test

# From tests directory
cd tests
pnpm test # All tests
pnpm test:verbose # Verbose output
pnpm test:watch # Watch mode
pnpm test:runtime # Runtime tests only
pnpm test:observability # Observability tests only
Comment thread
mrunalhirve128 marked this conversation as resolved.
Outdated

# Run specific test file
pnpm test -- runtime/power-platform-api-discovery.test.ts

# Additional options
pnpm test -- --testPathPattern=observability
pnpm test -- --testNamePattern="should return"
pnpm test -- --bail # Stop on first failure
pnpm test -- --onlyFailures # Re-run failed tests only
```

### VS Code Test Explorer (Optional)

1. Install Jest extension (Orta.vscode-jest)
2. Click beaker icon or `Ctrl+Shift+P` → "Test: Focus on Test Explorer View"
3. Click play button to run tests or right-click → "Debug Test"

---

## Coverage Reports

**⚠️ TODO**: Coverage shows 0% due to Jest + ts-jest + moduleNameMapper limitation in monorepos. Tests execute correctly and validate functionality, but coverage metrics aren't collected.

```powershell
cd tests

# Generate coverage reports
pnpm test:coverage # All formats
pnpm test:coverage:html # HTML only
Comment thread
mrunalhirve128 marked this conversation as resolved.
Outdated
pnpm test:ci # CI mode

# View HTML report
Comment thread
mrunalhirve128 marked this conversation as resolved.
Outdated
start coverage\index.html # Windows
open coverage/index.html # Mac/Linux
```

**Report Formats**: HTML (`coverage/index.html`), LCOV (`lcov.info`), Cobertura (`cobertura-coverage.xml`)

---

## Troubleshooting

### Quick Fixes

| Issue | Solution |
|-------|----------|
| Test loading failed | `pnpm install && pnpm build`, restart VS Code |
| Cannot find module | `pnpm build` from repository root |
| Tests not discovered | Check `.vscode/settings.json`, reload window |

### Complete Reset

```powershell
# From repository root
pnpm install
pnpm build
pnpm test -- --clearCache

# Restart VS Code: Ctrl+Shift+P → "Developer: Reload Window"
```

### VS Code Configuration

Create `.vscode/settings.json` if Test Explorer doesn't work:

```json
{
"jest.rootPath": "tests",
"jest.jestCommandLine": "pnpm test",
"jest.autoRun": "off"
}
```
148 changes: 148 additions & 0 deletions tests/TEST_PLAN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
# Test Plan for Agent365-nodejs SDK

> **Note:** This plan is under active development. Keep updating as testing progresses.

**Version:** 1.0
**Date:** November 25, 2025
Comment thread
mrunalhirve128 marked this conversation as resolved.
Outdated
**Status:** Draft

---

## Overview

### Current State
- ✅ Unit tests exist for `observability` and `runtime` modules
- ❌ Missing tests for `tooling` and `notifications` modules
- ❌ No integration tests or CI/CD automation

### Goals
- Achieve **80%+ code coverage** across all modules
- Implement integration tests for cross-module functionality
- Integrate testing into CI/CD pipeline with coverage enforcement

---

## Testing Strategy

**Framework:** `Jest` with `ts-jest`
**Coverage:** `Jest Coverage`
**Mocking:** `jest.mock`
**Async:** Native async/await

**Test Pattern:** AAA (Arrange → Act → Assert)
**Test File Naming:** `<filename>.test.ts` (e.g., `power-platform-api-discovery.test.ts`)
**Test Naming Convention:** `'should <expected_result> when <condition>'`

---

## Implementation Roadmap

| Phase | Deliverables | Priority |
|-------|-------------|----------|
| 1.1 | Runtime unit tests | ✅ Partial |
| 1.2 | Tooling unit tests | HIGH |
| 1.3 | Notifications unit tests | HIGH |
| 1.4 | Expand observability tests | MEDIUM |
| 1.5 | Tooling extension tests | MEDIUM |
| 2 | Integration tests | MEDIUM |
| 3 | CI/CD automation | HIGH |

---

## Phase 1: Unit Tests

### 1.1 Runtime Module

**Priority:** HIGH

| Module | Test File | Status |
|--------|-----------|--------|
| `power-platform-api-discovery.ts` | `power-platform-api-discovery.test.ts` | ✅ Complete |
| `utility.ts` | `utility.test.ts` | ✅ Complete |
| `environment-utils.ts` | `environment-utils.test.ts` | ✅ Complete |
| `agentic-authorization-service.ts` | `agentic-authorization-service.test.ts` | ✅ Complete |

---

### 1.2 Tooling Module

**Priority:** HIGH

| Module | Test File | Status |
|--------|-----------|--------|
| `Utility.ts` | `Utility.test.ts` | ❌ Missing |
| `McpToolServerConfigurationService.ts` | `McpToolServerConfigurationService.test.ts` | ❌ Missing |

---

### 1.3 Notifications Module

**Priority:** HIGH

| Module | Test File | Status |
|--------|-----------|--------|
| `agent-notification.ts` | `agent-notification.test.ts` | ❌ Missing |
| `models/*` | Model tests | ❌ Missing |
| `extensions/*` | Extension tests | ❌ Missing |

---

### 1.4 Observability Extensions

**Priority:** MEDIUM

| Extension | Status |
|-----------|--------|
| `openai` | ✅ Expand existing |
| `tokencache` | ✅ Expand existing |

---

### 1.5 Tooling Extensions

**Priority:** LOW

| Extension | Status |
|-----------|--------|
| Claude | ❌ Missing |
| LangChain | ❌ Missing |
| OpenAI | ❌ Missing |

---

## Phase 2: Integration Tests

**Priority:** MEDIUM

| Integration | Status |
|-------------|--------|
| Runtime + Observability | ❌ Missing |
| Tooling + Runtime | ❌ Missing |
| Notifications + Runtime | ❌ Missing |
| OpenAI full flow | ✅ Complete |
| Claude full flow | ❌ Missing |
| LangChain full flow | ❌ Missing |

---

## Phase 3: CI/CD Integration

**Priority:** HIGH

| Component | Status |
|-----------|--------|
| GitHub Actions workflow | ❌ Missing |
| Node.js matrix (18.x, 20.x, 22.x) | ❌ Missing |
| Coverage enforcement (80%+) | ❌ Missing |
| Codecov integration | ❌ Missing |
| PR blocking on failures | ❌ Missing |

---

## Success Criteria

- ✅ 80%+ code coverage for all modules
- ✅ All tests pass independently
- ✅ Full suite completes in < 30 seconds (unit) / < 5 minutes (full)
- ✅ Automated test execution on all PRs
- ✅ Coverage reports visible and enforced
Loading