home / skills / dexploarer / hyper-forge / testing-helper

testing-helper skill

/.claude/skills/testing-helper

This skill generates comprehensive test suites for elizaOS components, including unit, integration, and end-to-end tests.

npx playbooks add skill dexploarer/hyper-forge --skill testing-helper

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
3.8 KB
---
name: testing-helper
description: Create comprehensive tests for elizaOS plugins, characters, and actions. Triggers on "create tests", "test elizaOS plugin", or "write agent tests"
allowed-tools: [Write, Read, Edit]
---

# Testing Helper Skill

Generate comprehensive test suites for elizaOS components with unit, integration, and E2E tests.

## Test Structure

```
__tests__/
├── unit/
│   ├── actions.test.ts
│   ├── providers.test.ts
│   ├── evaluators.test.ts
│   └── services.test.ts
├── integration/
│   ├── plugin.test.ts
│   └── character.test.ts
└── e2e/
    └── agent-flow.test.ts
```

## Action Tests

```typescript
import { describe, it, expect, beforeEach } from 'vitest';
import { myAction } from '../src/actions/myAction';
import { createMockRuntime, createMockMessage } from '@elizaos/core/test';

describe('MyAction', () => {
  let runtime: any;
  let message: any;

  beforeEach(() => {
    runtime = createMockRuntime();
    message = createMockMessage();
  });

  it('validates correct input', async () => {
    const valid = await myAction.validate(runtime, message);
    expect(valid).toBe(true);
  });

  it('rejects invalid input', async () => {
    message.content = {};
    const valid = await myAction.validate(runtime, message);
    expect(valid).toBe(false);
  });

  it('executes successfully', async () => {
    const result = await myAction.handler(runtime, message);
    expect(result).toBeDefined();
  });

  it('handles errors gracefully', async () => {
    runtime.createMemory = () => { throw new Error('Test error'); };
    const result = await myAction.handler(runtime, message);
    expect(result).toContain('failed');
  });
});
```

## Provider Tests

```typescript
describe('MyProvider', () => {
  it('returns valid data', async () => {
    const result = await myProvider.get(runtime, message);

    expect(result).toHaveProperty('values');
    expect(result).toHaveProperty('data');
    expect(result).toHaveProperty('text');
    expect(typeof result.text).toBe('string');
  });

  it('handles missing data', async () => {
    const result = await myProvider.get(runtime, null);
    expect(result.text).toBe('');
  });
});
```

## Character Tests

```typescript
describe('Character Configuration', () => {
  it('has required fields', () => {
    expect(character.name).toBeDefined();
    expect(character.bio).toBeDefined();
  });

  it('has valid plugins', () => {
    expect(character.plugins).toContain('@elizaos/plugin-bootstrap');
  });

  it('has valid message examples', () => {
    character.messageExamples?.forEach(conversation => {
      expect(Array.isArray(conversation)).toBe(true);
      conversation.forEach(msg => {
        expect(msg).toHaveProperty('name');
        expect(msg).toHaveProperty('content');
      });
    });
  });
});
```

## Integration Tests

```typescript
describe('Plugin Integration', () => {
  let runtime: AgentRuntime;

  beforeAll(async () => {
    runtime = new AgentRuntime({
      character: testCharacter,
      plugins: [myPlugin]
    });
    await runtime.initialize();
  });

  afterAll(async () => {
    await runtime.stop();
  });

  it('loads plugin correctly', () => {
    expect(runtime.plugins).toContain(myPlugin);
  });

  it('registers actions', () => {
    const action = runtime.actions.find(a => a.name === 'MY_ACTION');
    expect(action).toBeDefined();
  });
});
```

## E2E Tests

```typescript
describe('Agent Flow', () => {
  it('processes message end-to-end', async () => {
    const response = await runtime.processMessage({
      content: { text: 'Hello' },
      senderId: 'user-1',
      roomId: 'room-1'
    });

    expect(response.content.text).toBeDefined();
  });
});
```

## Coverage Requirements

- Unit tests: >80% code coverage
- Integration tests: All components
- E2E tests: Main user flows
- Error scenarios tested
- Edge cases covered

Overview

This skill generates comprehensive test suites for elizaOS plugins, characters, and actions. It scaffolds unit, integration, and end-to-end tests in TypeScript using typical elizaOS testing helpers and a Vitest-like style. The goal is reliable, repeatable validation of runtime behavior, data providers, and agent flows.

How this skill works

The skill inspects action validators and handlers, provider getters, character configuration, and plugin registration points to produce focused tests. It creates unit tests for validation, execution, and error handling, integration tests for plugin loading and action registration, and E2E specs that exercise full message processing. It also suggests coverage targets and edge-case scenarios to meet test requirements.

When to use it

  • When adding or refactoring an action, provider, or service to ensure behavior stays stable.
  • Before merging a new plugin or character to confirm integration with the runtime.
  • To create E2E checks that validate full agent message flows and user-facing outputs.
  • When enforcing coverage gates (>80% unit coverage) or documenting expected error handling.
  • During CI setup to auto-run unit, integration, and E2E suites against test characters.

Best practices

  • Mock the AgentRuntime and messages for unit tests to isolate logic and make tests deterministic.
  • Cover both success and error paths: validation, normal execution, and simulated runtime failures.
  • Write small, focused tests: one assertion intent per test to make failures easy to diagnose.
  • Group tests by type (unit/integration/e2e) and mirror the suggested directory structure for clarity.
  • Include representative message examples in character tests to validate content shapes and plugins.

Example use cases

  • Generate unit tests for a new action that validates input and creates memory entries.
  • Create provider tests that assert returned data shapes and behavior when inputs are missing.
  • Build integration tests that confirm a plugin loads and registers actions in the runtime.
  • Add an E2E test that sends a message through the runtime and asserts the final agent response.
  • Enforce CI coverage rules by producing tests that target error handling and edge cases.

FAQ

Which testing libraries does the skill target?

It produces TypeScript-friendly tests compatible with Vitest/Jest style APIs and uses common elizaOS test helpers where available.

How does it handle runtime dependencies?

The generated tests prefer mocked runtimes and helpers for unit tests and use a real or instrumented AgentRuntime for integration and E2E scenarios.