| file_type | documentation | |
|---|---|---|
| title | Agent Test Suite | |
| description | Comprehensive Jest tests for all LightSpeed agents | |
| version | v1.1 | |
| created_date | 2026-05-29 | |
| last_updated | 2026-05-29 | |
| maintainer | LightSpeed Team | |
| authors |
|
|
| license | GPL-3.0 | |
| stability | stable | |
| domain | governance | |
| tags |
This directory contains comprehensive Jest tests for all LightSpeed agents, ensuring reliability, correctness, and consistent behavior across automation workflows.
Last Updated: 2025-11-25 Status: β All agent files validated
All agent specification files pass frontmatter validation:
node scripts/validation/validate-agent-frontmatter.jsResult: β 14/14 files passing
| Agent File | Status |
|---|---|
| badges.agent.md | β Valid |
| meta.agent.md | β Valid |
| header-footer.agent.md | β Valid |
| issue-type.agent.md | β Valid |
| jsdoc-review.agent.md | β Valid |
| label-standardization.agent.md | β Valid |
| labeling.agent.md | β Valid |
| linting.agent.md | β Valid |
| manage-readmes.agent.md | β Valid |
| metrics.agent.md | β Valid |
| planner.agent.md | β Valid |
| release.agent.md | β Valid |
| reviewer.agent.md | β Valid |
| template.agent.md | β Valid |
See Validation Report for full details.
| File | Agent Tested | Purpose |
|---|---|---|
template.agent.test.js |
template.agent.js | Tests basic agent structure and initialization |
issue-type.agent.test.js |
issue-type.agent.js | Tests issue type detection and assignment |
label-standardization.agent.test.js |
label-standardization.agent.js | Tests label normalization and migration |
labeling.agent.test.js |
labeling.agent.js | Tests unified labeling workflow |
labeling.agent.integration.test.js |
labeling.agent.js | Integration tests with GitHub API mocks |
reviewer.agent.test.js |
reviewer.agent.js | Tests PR review automation |
planner.agent.test.js |
planner.agent.js | Tests PR checklist generation |
| File | Purpose |
|---|---|
agent-performance.test.js |
Performance benchmarks for agents |
agent-workflows.test.js |
Tests agent integration with GitHub workflows |
test-mock-validation.test.js |
Validates test mocks and helpers |
npm test -- .github/agents/__tests__/npm test -- .github/agents/__tests__/labeling.agent.test.jsnpm test -- .github/agents/__tests__/ --coveragenpm test -- .github/agents/__tests__/ --watchnpm test -- .github/agents/__tests__/labeling.agent.test.js -t "applies default status"- Overall Coverage: β₯85%
- Statements: β₯85%
- Branches: β₯80%
- Functions: β₯85%
- Lines: β₯85%
View current coverage:
npm test -- .github/agents/__tests__/ --coverage
open coverage/lcov-report/index.html- Individual function logic
- Error handling and edge cases
- Parameter validation
- Return value correctness
- Multiple functions working together
- API mocking with octokit
- GitHub Actions context simulation
- Real workflow scenarios
- Agent execution time benchmarks
- Memory usage optimization
- Concurrent operation handling
- Large dataset processing
Located in test-helpers.js (parent directory):
import {
mockOctokit,
mockContext,
mockPrPayload,
mockIssuePayload,
setTestEnv,
resetTestEnv,
expectCommentPosted,
expectDryRun,
} from "../../test-helpers.js";Creates a mocked GitHub API client with standard REST endpoints.
const octokit = mockOctokit();
octokit.rest.issues.addLabels.mockResolvedValue({ data: {} });Creates a GitHub Actions context object.
const context = mockContext(
mockPrPayload({
labels: [{ name: "type:feature" }],
}),
);Generates a pull request event payload.
const payload = mockPrPayload({
number: 123,
title: "Test PR",
});Generates an issue event payload.
const payload = mockIssuePayload({
number: 456,
title: "Test Issue",
});Sets environment variables for tests.
setTestEnv({ GITHUB_TOKEN: "test-token" });Clears specific environment variables after tests.
afterEach(() => resetTestEnv(["GITHUB_TOKEN"]));const { mockOctokit, mockContext } = require("../../test-helpers");
const { run } = require("../your-agent.js");
describe("Your Agent", () => {
beforeAll(() => {
// Setup before all tests
});
afterAll(() => {
// Cleanup after all tests
});
beforeEach(() => {
// Setup before each test
});
afterEach(() => {
// Cleanup after each test
});
test("should perform expected action", async () => {
// Arrange
const octokit = mockOctokit();
const context = mockContext(mockPrPayload());
// Act
await run(context);
// Assert
expect(octokit.rest.issues.addLabels).toHaveBeenCalled();
});
});-
Clear Test Names: Describe what the test validates, not how
// β Good test("should add default status label when missing", async () => {}); // β Avoid test("tests status labels", async () => {});
-
Arrange-Act-Assert Pattern: Organize test logic clearly
// Arrange - set up test data const input = { labels: [] }; // Act - perform the action const result = await runAgent(input); // Assert - verify the result expect(result.labels).toContain("status:needs-review");
-
Mock External Dependencies: Don't make real API calls
// β Good const octokit = mockOctokit(); // β Avoid const octokit = github.getOctokit(process.env.GITHUB_TOKEN);
-
Test Both Success and Failure Paths
test("should handle successful case", async () => { /* ... */ }); test("should throw error when input invalid", async () => { /* ... */ });
-
Use Meaningful Assertions
// β Good expect(result.labels).toHaveLength(1); expect(result.labels[0]).toBe("status:needs-review"); // β Avoid expect(result.labels.length).toBe(1);
node --inspect-brk ./node_modules/.bin/jest .github/agents/__tests__/ --runInBandtest("debug test", async () => {
const result = await runAgent(input);
console.log("DEBUG:", JSON.stringify(result, null, 2));
expect(result).toBeDefined();
});npm test -- .github/agents/__tests__/ --verbose- Agent Specifications - Main agents directory
- Agent Includes - Shared utility modules
- Quality Assurance - Testing strategy, coverage, and CI integration
- Jest Configuration - Jest setup and configuration
All agent tests run automatically on:
- Pull Requests: All tests must pass before merge
- Pushes to develop: Validates code quality
- Pre-commit: Local hook runs affected tests
View CI status in GitHub Actions: .github/workflows/jest-test-audit.yml