@elizaos/cli 1.3.2 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -0
- package/dist/{bun-exec-6CQHTS4F.js → bun-exec-ULMPAIQC.js} +1 -1
- package/dist/{chunk-E6XYTE3A.js → chunk-D3QSET5H.js} +69 -72
- package/dist/{chunk-FDEDLANP.js → chunk-FQYWRHLX.js} +1 -1
- package/dist/{chunk-T2QDIXGU.js → chunk-FSSUAWXQ.js} +3 -3
- package/dist/{chunk-D3Q2UZLZ.js → chunk-I4L4T7QX.js} +1 -1
- package/dist/{chunk-5GUS4CFO.js → chunk-SMZBJQJR.js} +1 -1
- package/dist/commands/agent/actions/index.js +3 -3
- package/dist/commands/agent/index.js +3 -3
- package/dist/commands/create/actions/index.js +4 -4
- package/dist/commands/create/index.js +5 -5
- package/dist/index.js +134 -109
- package/dist/{plugin-creator-H26ZLR6H.js → plugin-creator-TCUFII32.js} +2 -2
- package/dist/{registry-433S5F3Y.js → registry-RF6PW3EN.js} +3 -3
- package/dist/templates/plugin-quick-starter/README.md +52 -10
- package/dist/templates/plugin-quick-starter/package.json +2 -2
- package/dist/templates/plugin-quick-starter/src/__tests__/e2e/README.md +140 -0
- package/dist/templates/plugin-quick-starter/src/__tests__/e2e/plugin-quick-starter.e2e.ts +339 -0
- package/dist/templates/plugin-quick-starter/src/__tests__/plugin.test.ts +55 -17
- package/dist/templates/plugin-quick-starter/src/plugin.ts +14 -14
- package/dist/templates/plugin-starter/README.md +124 -49
- package/dist/templates/plugin-starter/package.json +2 -2
- package/dist/templates/plugin-starter/src/__tests__/e2e/README.md +44 -9
- package/{templates/plugin-starter/src/__tests__/e2e/starter-plugin.ts → dist/templates/plugin-starter/src/__tests__/e2e/plugin-starter.e2e.ts} +13 -20
- package/dist/templates/plugin-starter/src/plugin.ts +5 -7
- package/dist/templates/project-starter/README.md +24 -11
- package/dist/templates/project-starter/package.json +4 -4
- package/dist/templates/project-starter/src/__tests__/actions.test.ts +2 -2
- package/dist/templates/project-starter/src/__tests__/e2e/README.md +103 -0
- package/dist/templates/project-starter/src/__tests__/e2e/project-starter.e2e.ts +575 -0
- package/dist/templates/project-starter/src/__tests__/integration.test.ts +1 -1
- package/dist/templates/project-starter/src/__tests__/models.test.ts +3 -3
- package/dist/templates/project-starter/src/__tests__/plugin.test.ts +3 -3
- package/dist/templates/project-starter/src/__tests__/provider.test.ts +2 -2
- package/dist/templates/project-starter/src/index.ts +4 -3
- package/dist/templates/project-starter/src/plugin.ts +5 -5
- package/dist/templates/project-tee-starter/README.md +44 -5
- package/dist/templates/project-tee-starter/package.json +4 -4
- package/dist/templates/project-tee-starter/{__tests__ → src/__tests__}/build-order.test.ts +1 -1
- package/{templates/project-tee-starter → dist/templates/project-tee-starter/src}/__tests__/character.test.ts +1 -1
- package/dist/templates/project-tee-starter/{__tests__ → src/__tests__}/config.test.ts +1 -1
- package/dist/templates/project-tee-starter/src/__tests__/e2e/README.md +128 -0
- package/dist/templates/project-tee-starter/src/__tests__/e2e/project-tee-starter.e2e.ts +280 -0
- package/dist/templates/project-tee-starter/{__tests__ → src/__tests__}/env.test.ts +1 -1
- package/{templates/project-tee-starter → dist/templates/project-tee-starter/src}/__tests__/error-handling.test.ts +2 -2
- package/{templates/project-tee-starter → dist/templates/project-tee-starter/src}/__tests__/events.test.ts +1 -1
- package/{templates/project-tee-starter → dist/templates/project-tee-starter/src}/__tests__/file-structure.test.ts +2 -2
- package/{templates/project-tee-starter → dist/templates/project-tee-starter/src}/__tests__/integration.test.ts +2 -2
- package/dist/templates/project-tee-starter/{__tests__ → src/__tests__}/models.test.ts +1 -1
- package/{templates/project-tee-starter → dist/templates/project-tee-starter/src}/__tests__/plugin.test.ts +1 -1
- package/dist/templates/project-tee-starter/{__tests__ → src/__tests__}/provider.test.ts +2 -2
- package/{templates/project-tee-starter → dist/templates/project-tee-starter/src}/__tests__/routes.test.ts +1 -1
- package/{templates/project-tee-starter → dist/templates/project-tee-starter/src}/__tests__/tee-validation.test.ts +1 -1
- package/{templates/project-tee-starter → dist/templates/project-tee-starter/src}/__tests__/test-utils.ts +2 -2
- package/{templates/project-tee-starter → dist/templates/project-tee-starter/src}/__tests__/vite-config-utils.ts +14 -2
- package/dist/templates/project-tee-starter/src/index.ts +2 -0
- package/dist/templates/project-tee-starter/src/plugin.ts +19 -7
- package/dist/{utils-DBLSDYBF.js → utils-5HPZSIF6.js} +3 -3
- package/package.json +6 -6
- package/templates/plugin-quick-starter/README.md +52 -10
- package/templates/plugin-quick-starter/package.json +2 -2
- package/templates/plugin-quick-starter/src/__tests__/e2e/README.md +140 -0
- package/templates/plugin-quick-starter/src/__tests__/e2e/plugin-quick-starter.e2e.ts +339 -0
- package/templates/plugin-quick-starter/src/__tests__/plugin.test.ts +55 -17
- package/templates/plugin-quick-starter/src/plugin.ts +14 -14
- package/templates/plugin-starter/README.md +124 -49
- package/templates/plugin-starter/package.json +2 -2
- package/templates/plugin-starter/src/__tests__/e2e/README.md +44 -9
- package/{dist/templates/plugin-starter/src/__tests__/e2e/starter-plugin.ts → templates/plugin-starter/src/__tests__/e2e/plugin-starter.e2e.ts} +13 -20
- package/templates/plugin-starter/src/plugin.ts +5 -7
- package/templates/project-starter/README.md +24 -11
- package/templates/project-starter/package.json +4 -4
- package/templates/project-starter/src/__tests__/actions.test.ts +2 -2
- package/templates/project-starter/src/__tests__/e2e/README.md +103 -0
- package/templates/project-starter/src/__tests__/e2e/project-starter.e2e.ts +575 -0
- package/templates/project-starter/src/__tests__/integration.test.ts +1 -1
- package/templates/project-starter/src/__tests__/models.test.ts +3 -3
- package/templates/project-starter/src/__tests__/plugin.test.ts +3 -3
- package/templates/project-starter/src/__tests__/provider.test.ts +2 -2
- package/templates/project-starter/src/index.ts +4 -3
- package/templates/project-starter/src/plugin.ts +5 -5
- package/templates/project-tee-starter/README.md +44 -5
- package/templates/project-tee-starter/package.json +4 -4
- package/templates/project-tee-starter/{__tests__ → src/__tests__}/build-order.test.ts +1 -1
- package/{dist/templates/project-tee-starter → templates/project-tee-starter/src}/__tests__/character.test.ts +1 -1
- package/templates/project-tee-starter/{__tests__ → src/__tests__}/config.test.ts +1 -1
- package/templates/project-tee-starter/src/__tests__/e2e/README.md +128 -0
- package/templates/project-tee-starter/src/__tests__/e2e/project-tee-starter.e2e.ts +280 -0
- package/templates/project-tee-starter/{__tests__ → src/__tests__}/env.test.ts +1 -1
- package/{dist/templates/project-tee-starter → templates/project-tee-starter/src}/__tests__/error-handling.test.ts +2 -2
- package/{dist/templates/project-tee-starter → templates/project-tee-starter/src}/__tests__/events.test.ts +1 -1
- package/{dist/templates/project-tee-starter → templates/project-tee-starter/src}/__tests__/file-structure.test.ts +2 -2
- package/{dist/templates/project-tee-starter → templates/project-tee-starter/src}/__tests__/integration.test.ts +2 -2
- package/templates/project-tee-starter/{__tests__ → src/__tests__}/models.test.ts +1 -1
- package/{dist/templates/project-tee-starter → templates/project-tee-starter/src}/__tests__/plugin.test.ts +1 -1
- package/templates/project-tee-starter/{__tests__ → src/__tests__}/provider.test.ts +2 -2
- package/{dist/templates/project-tee-starter → templates/project-tee-starter/src}/__tests__/routes.test.ts +1 -1
- package/{dist/templates/project-tee-starter → templates/project-tee-starter/src}/__tests__/tee-validation.test.ts +1 -1
- package/{dist/templates/project-tee-starter → templates/project-tee-starter/src}/__tests__/test-utils.ts +2 -2
- package/{dist/templates/project-tee-starter → templates/project-tee-starter/src}/__tests__/vite-config-utils.ts +14 -2
- package/templates/project-tee-starter/src/index.ts +2 -0
- package/templates/project-tee-starter/src/plugin.ts +19 -7
- package/dist/templates/plugin-starter/src/tests.ts +0 -6
- package/dist/templates/project-starter/src/__tests__/e2e/index.ts +0 -14
- package/dist/templates/project-starter/src/__tests__/e2e/natural-language.test.ts +0 -246
- package/dist/templates/project-starter/src/__tests__/e2e/project.test.ts +0 -155
- package/dist/templates/project-starter/src/__tests__/e2e/starter-plugin.test.ts +0 -421
- package/dist/templates/project-tee-starter/e2e/project.test.ts +0 -38
- package/dist/templates/project-tee-starter/e2e/starter-plugin.test.ts +0 -92
- package/templates/plugin-starter/src/tests.ts +0 -6
- package/templates/project-starter/src/__tests__/e2e/index.ts +0 -14
- package/templates/project-starter/src/__tests__/e2e/natural-language.test.ts +0 -246
- package/templates/project-starter/src/__tests__/e2e/project.test.ts +0 -155
- package/templates/project-starter/src/__tests__/e2e/starter-plugin.test.ts +0 -421
- package/templates/project-tee-starter/e2e/project.test.ts +0 -38
- package/templates/project-tee-starter/e2e/starter-plugin.test.ts +0 -92
- /package/dist/templates/project-tee-starter/{__tests__ → src/__tests__}/actions.test.ts +0 -0
- /package/dist/templates/project-tee-starter/{__tests__ → src/__tests__}/frontend.test.ts +0 -0
- /package/dist/templates/project-tee-starter/{__tests__ → src/__tests__}/utils/core-test-utils.ts +0 -0
- /package/templates/project-tee-starter/{__tests__ → src/__tests__}/actions.test.ts +0 -0
- /package/templates/project-tee-starter/{__tests__ → src/__tests__}/frontend.test.ts +0 -0
- /package/templates/project-tee-starter/{__tests__ → src/__tests__}/utils/core-test-utils.ts +0 -0
|
@@ -34,89 +34,164 @@ elizaos test
|
|
|
34
34
|
|
|
35
35
|
## Testing
|
|
36
36
|
|
|
37
|
-
ElizaOS
|
|
37
|
+
ElizaOS uses a dual testing approach that combines Bun's native test runner for component tests with a custom E2E test runner for integration testing within a live ElizaOS runtime.
|
|
38
38
|
|
|
39
39
|
### Test Structure
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
- Test the plugin within a full ElizaOS runtime
|
|
50
|
-
- Validate complete user scenarios with a real agent
|
|
51
|
-
- Run with: `elizaos test e2e`
|
|
41
|
+
```
|
|
42
|
+
src/
|
|
43
|
+
__tests__/ # All tests live inside src
|
|
44
|
+
*.test.ts # Component tests (use Bun test runner)
|
|
45
|
+
e2e/ # E2E tests (use ElizaOS test runner)
|
|
46
|
+
*.ts # E2E test files
|
|
47
|
+
README.md # E2E testing documentation
|
|
48
|
+
```
|
|
52
49
|
|
|
53
|
-
|
|
54
|
-
- `elizaos test` runs both component and e2e tests
|
|
50
|
+
### Two Types of Tests
|
|
55
51
|
|
|
56
|
-
|
|
52
|
+
#### 1. Component Tests (Bun Test Runner)
|
|
57
53
|
|
|
58
|
-
|
|
54
|
+
- **Purpose**: Test individual functions/classes in isolation
|
|
55
|
+
- **Location**: `src/__tests__/*.test.ts`
|
|
56
|
+
- **Runner**: Bun's built-in test runner
|
|
57
|
+
- **Command**: `bun test`
|
|
58
|
+
- **Features**: Fast, isolated, uses mocks
|
|
59
59
|
|
|
60
60
|
```typescript
|
|
61
|
-
//
|
|
61
|
+
// Example: src/__tests__/plugin.test.ts
|
|
62
|
+
import { describe, it, expect } from 'bun:test';
|
|
63
|
+
import { starterPlugin } from '../plugin';
|
|
64
|
+
|
|
62
65
|
describe('Plugin Configuration', () => {
|
|
63
66
|
it('should have correct plugin metadata', () => {
|
|
64
67
|
expect(starterPlugin.name).toBe('plugin-starter');
|
|
65
68
|
});
|
|
66
69
|
});
|
|
67
|
-
|
|
68
|
-
// Integration test example (__tests__/integration.test.ts)
|
|
69
|
-
describe('Integration: HelloWorld Action with StarterService', () => {
|
|
70
|
-
it('should handle HelloWorld action with StarterService', async () => {
|
|
71
|
-
// Test interactions between components
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
70
|
```
|
|
75
71
|
|
|
76
|
-
|
|
72
|
+
#### 2. E2E Tests (ElizaOS Test Runner)
|
|
73
|
+
|
|
74
|
+
- **Purpose**: Test plugin behavior within a real ElizaOS runtime
|
|
75
|
+
- **Location**: `src/__tests__/e2e/*.ts`
|
|
76
|
+
- **Runner**: ElizaOS custom test runner
|
|
77
|
+
- **Command**: `elizaos test --type e2e`
|
|
78
|
+
- **Features**: Real runtime, real database, full integration
|
|
77
79
|
|
|
78
80
|
```typescript
|
|
79
|
-
//
|
|
81
|
+
// Example: src/__tests__/e2e/starter-plugin.ts
|
|
82
|
+
import { type TestSuite } from '@elizaos/core';
|
|
83
|
+
|
|
80
84
|
export const StarterPluginTestSuite: TestSuite = {
|
|
81
85
|
name: 'plugin_starter_test_suite',
|
|
82
|
-
description: 'E2E tests for the starter plugin',
|
|
83
86
|
tests: [
|
|
84
87
|
{
|
|
85
88
|
name: 'hello_world_action_test',
|
|
86
89
|
fn: async (runtime) => {
|
|
87
|
-
//
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
// Execute action and capture response
|
|
93
|
-
const response = await helloWorldAction.handler(runtime, testMessage, ...);
|
|
94
|
-
|
|
95
|
-
// Verify agent responds with "hello world"
|
|
96
|
-
if (!response.text.includes('hello world')) {
|
|
97
|
-
throw new Error('Expected "hello world" in response');
|
|
90
|
+
// Test with real runtime - no mocks needed!
|
|
91
|
+
const action = runtime.actions.find((a) => a.name === 'HELLO_WORLD');
|
|
92
|
+
if (!action) {
|
|
93
|
+
throw new Error('Action not found');
|
|
98
94
|
}
|
|
95
|
+
// Test real behavior...
|
|
99
96
|
},
|
|
100
97
|
},
|
|
101
98
|
],
|
|
102
99
|
};
|
|
103
100
|
```
|
|
104
101
|
|
|
105
|
-
|
|
102
|
+
### Running Tests
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
# Run all tests (both component and E2E)
|
|
106
|
+
elizaos test
|
|
107
|
+
|
|
108
|
+
# Run only component tests (fast, for TDD)
|
|
109
|
+
bun test
|
|
110
|
+
# or
|
|
111
|
+
elizaos test --type component
|
|
112
|
+
|
|
113
|
+
# Run only E2E tests (slower, full integration)
|
|
114
|
+
elizaos test --type e2e
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Key Differences
|
|
118
|
+
|
|
119
|
+
| Aspect | Component Tests | E2E Tests |
|
|
120
|
+
| --------------- | -------------------- | ----------------------- |
|
|
121
|
+
| **Runner** | Bun test | ElizaOS TestRunner |
|
|
122
|
+
| **Environment** | Mocked | Real runtime |
|
|
123
|
+
| **Database** | Mocked | Real (PGLite) |
|
|
124
|
+
| **Speed** | Fast (ms) | Slower (seconds) |
|
|
125
|
+
| **Use Case** | TDD, component logic | Integration, user flows |
|
|
126
|
+
|
|
127
|
+
### E2E Test Integration
|
|
128
|
+
|
|
129
|
+
E2E tests are integrated into your plugin by:
|
|
130
|
+
|
|
131
|
+
1. **Creating the test suite** in `src/__tests__/e2e/`
|
|
132
|
+
2. **Importing directly** in your plugin definition:
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
// src/plugin.ts
|
|
136
|
+
import { StarterPluginTestSuite } from './__tests__/e2e/starter-plugin';
|
|
137
|
+
|
|
138
|
+
export const starterPlugin: Plugin = {
|
|
139
|
+
name: 'plugin-starter',
|
|
140
|
+
// ... other properties
|
|
141
|
+
tests: [StarterPluginTestSuite], // Direct import, no tests.ts needed
|
|
142
|
+
};
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Writing Effective E2E Tests
|
|
146
|
+
|
|
147
|
+
E2E tests receive a real `IAgentRuntime` instance, allowing you to:
|
|
148
|
+
|
|
149
|
+
- Access real actions, providers, and services
|
|
150
|
+
- Interact with the actual database
|
|
151
|
+
- Test complete user scenarios
|
|
152
|
+
- Validate plugin behavior in production-like conditions
|
|
153
|
+
|
|
154
|
+
```typescript
|
|
155
|
+
{
|
|
156
|
+
name: 'service_lifecycle_test',
|
|
157
|
+
fn: async (runtime) => {
|
|
158
|
+
// Get the real service
|
|
159
|
+
const service = runtime.getService('starter');
|
|
160
|
+
if (!service) {
|
|
161
|
+
throw new Error('Service not initialized');
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// Test real behavior
|
|
165
|
+
await service.stop();
|
|
166
|
+
// Verify cleanup happened...
|
|
167
|
+
},
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Best Practices
|
|
172
|
+
|
|
173
|
+
1. **Use Component Tests for**:
|
|
174
|
+
|
|
175
|
+
- Algorithm logic
|
|
176
|
+
- Data transformations
|
|
177
|
+
- Input validation
|
|
178
|
+
- Error handling
|
|
106
179
|
|
|
107
|
-
|
|
108
|
-
- **Plugin Interaction**: Test how your plugin behaves with the actual agent
|
|
109
|
-
- **Scenario Testing**: Validate complete user interactions, not just individual functions
|
|
110
|
-
- **No Mock Required**: Access real services, actions, and providers
|
|
180
|
+
2. **Use E2E Tests for**:
|
|
111
181
|
|
|
112
|
-
|
|
182
|
+
- User scenarios
|
|
183
|
+
- Action execution flows
|
|
184
|
+
- Provider data integration
|
|
185
|
+
- Service lifecycle
|
|
186
|
+
- Plugin interactions
|
|
113
187
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
188
|
+
3. **Test Organization**:
|
|
189
|
+
- Keep related tests together
|
|
190
|
+
- Use descriptive test names
|
|
191
|
+
- Include failure scenarios
|
|
192
|
+
- Document complex test setups
|
|
118
193
|
|
|
119
|
-
The test
|
|
194
|
+
The comprehensive E2E test documentation in `src/__tests__/e2e/README.md` provides detailed examples and patterns for writing effective tests.
|
|
120
195
|
|
|
121
196
|
## Publishing & Continuous Development
|
|
122
197
|
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"tsup.config.ts"
|
|
42
42
|
],
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@elizaos/core": "1.
|
|
44
|
+
"@elizaos/core": "1.4.2",
|
|
45
45
|
"@tanstack/react-query": "^5.80.7",
|
|
46
46
|
"clsx": "^2.1.1",
|
|
47
47
|
"tailwind-merge": "^3.3.1",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"zod": "3.24.2"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@elizaos/cli": "1.
|
|
53
|
+
"@elizaos/cli": "1.4.2",
|
|
54
54
|
"@tailwindcss/vite": "^4.1.10",
|
|
55
55
|
"@vitejs/plugin-react-swc": "^3.10.2",
|
|
56
56
|
"dotenv": "16.4.5",
|
|
@@ -2,9 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
This directory contains end-to-end tests for the ElizaOS plugin starter template.
|
|
4
4
|
|
|
5
|
+
## ElizaOS Testing Philosophy
|
|
6
|
+
|
|
7
|
+
ElizaOS employs a dual testing strategy:
|
|
8
|
+
|
|
9
|
+
1. **Component Tests** (`src/__tests__/*.test.ts`)
|
|
10
|
+
|
|
11
|
+
- Run with Bun's native test runner
|
|
12
|
+
- Fast, isolated tests using mocks
|
|
13
|
+
- Perfect for TDD and component logic
|
|
14
|
+
- Command: `bun test`
|
|
15
|
+
|
|
16
|
+
2. **E2E Tests** (`src/__tests__/e2e/*.ts`)
|
|
17
|
+
- Run with ElizaOS custom test runner
|
|
18
|
+
- Real runtime with actual database (PGLite)
|
|
19
|
+
- Test complete user scenarios
|
|
20
|
+
- Command: `elizaos test --type e2e`
|
|
21
|
+
|
|
5
22
|
## Overview
|
|
6
23
|
|
|
7
|
-
E2E tests run in a real ElizaOS runtime environment, allowing you to test your plugin's behavior as it would work in production.
|
|
24
|
+
E2E tests run in a real ElizaOS runtime environment, allowing you to test your plugin's behavior as it would work in production. Unlike component tests, E2E tests provide access to a fully initialized runtime with all services, actions, and providers available.
|
|
8
25
|
|
|
9
26
|
## Test Structure
|
|
10
27
|
|
|
@@ -15,24 +32,42 @@ E2E tests run in a real ElizaOS runtime environment, allowing you to test your p
|
|
|
15
32
|
- `hello_world_provider_test` - Tests provider functionality
|
|
16
33
|
- `starter_service_test` - Tests service lifecycle
|
|
17
34
|
|
|
35
|
+
## Integration with Plugin
|
|
36
|
+
|
|
37
|
+
E2E tests are integrated directly into your plugin without the need for an intermediate export file:
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
// src/plugin.ts
|
|
41
|
+
import { StarterPluginTestSuite } from './__tests__/e2e/plugin-starter.e2e';
|
|
42
|
+
|
|
43
|
+
export const myPlugin: Plugin = {
|
|
44
|
+
name: 'my-plugin',
|
|
45
|
+
// ... other properties
|
|
46
|
+
tests: [StarterPluginTestSuite], // Direct import!
|
|
47
|
+
};
|
|
48
|
+
```
|
|
49
|
+
|
|
18
50
|
## Running Tests
|
|
19
51
|
|
|
20
52
|
```bash
|
|
21
53
|
# Run all tests (component + e2e)
|
|
22
|
-
|
|
54
|
+
elizaos test
|
|
23
55
|
|
|
24
|
-
# Run only e2e tests
|
|
25
|
-
|
|
56
|
+
# Run only e2e tests (slower, full integration)
|
|
57
|
+
elizaos test --type e2e
|
|
26
58
|
|
|
27
|
-
# Run only component tests
|
|
28
|
-
|
|
59
|
+
# Run only component tests (fast, for TDD)
|
|
60
|
+
bun test
|
|
61
|
+
# or
|
|
62
|
+
elizaos test --type component
|
|
29
63
|
```
|
|
30
64
|
|
|
31
65
|
## Implementation Details
|
|
32
66
|
|
|
33
|
-
1. **
|
|
67
|
+
1. **Direct Import**: Tests are imported directly from the e2e test file - no intermediate export file needed
|
|
34
68
|
2. **Plugin Integration**: The test suite is added to the plugin's `tests` array
|
|
35
|
-
3. **
|
|
69
|
+
3. **Test Discovery**: The ElizaOS test runner automatically finds and executes tests from the plugin's `tests` array
|
|
70
|
+
4. **Runtime Access**: Each test receives a real runtime instance with full access to:
|
|
36
71
|
- Plugin actions, providers, and services
|
|
37
72
|
- Agent character configuration
|
|
38
73
|
- Database and model access
|
|
@@ -44,4 +79,4 @@ npm run test:component
|
|
|
44
79
|
|
|
45
80
|
## Writing New Tests
|
|
46
81
|
|
|
47
|
-
See the comprehensive documentation at the top of `starter
|
|
82
|
+
See the comprehensive documentation at the top of `plugin-starter.e2e.ts` for detailed instructions on adding new tests.
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
type Content,
|
|
3
|
+
type HandlerCallback,
|
|
4
|
+
type IAgentRuntime,
|
|
5
|
+
type TestSuite,
|
|
6
|
+
} from '@elizaos/core';
|
|
2
7
|
|
|
3
8
|
/**
|
|
4
9
|
* E2E (End-to-End) Test Suite for ElizaOS Plugins
|
|
@@ -31,7 +36,7 @@ import { type Content, type HandlerCallback } from '@elizaos/core';
|
|
|
31
36
|
* ```typescript
|
|
32
37
|
* {
|
|
33
38
|
* name: 'my_new_test',
|
|
34
|
-
* fn: async (runtime) => {
|
|
39
|
+
* fn: async (runtime: IAgentRuntime) => {
|
|
35
40
|
* // Your test logic here
|
|
36
41
|
* if (someCondition !== expected) {
|
|
37
42
|
* throw new Error('Test failed: reason');
|
|
@@ -60,16 +65,6 @@ import { type Content, type HandlerCallback } from '@elizaos/core';
|
|
|
60
65
|
* For more details, see the ElizaOS documentation.
|
|
61
66
|
*/
|
|
62
67
|
|
|
63
|
-
// Define a minimal TestSuite interface that matches what's needed
|
|
64
|
-
interface TestSuite {
|
|
65
|
-
name: string;
|
|
66
|
-
description?: string;
|
|
67
|
-
tests: Array<{
|
|
68
|
-
name: string;
|
|
69
|
-
fn: (runtime: any) => Promise<any>;
|
|
70
|
-
}>;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
68
|
// Define minimal interfaces for the types we need
|
|
74
69
|
type UUID = `${string}-${string}-${string}-${string}-${string}`;
|
|
75
70
|
|
|
@@ -91,8 +86,6 @@ interface State {
|
|
|
91
86
|
|
|
92
87
|
export const StarterPluginTestSuite: TestSuite = {
|
|
93
88
|
name: 'plugin_starter_test_suite',
|
|
94
|
-
description: 'E2E tests for the starter plugin',
|
|
95
|
-
|
|
96
89
|
tests: [
|
|
97
90
|
/**
|
|
98
91
|
* Basic Plugin Verification Test
|
|
@@ -102,7 +95,7 @@ export const StarterPluginTestSuite: TestSuite = {
|
|
|
102
95
|
*/
|
|
103
96
|
{
|
|
104
97
|
name: 'example_test',
|
|
105
|
-
fn: async (runtime) => {
|
|
98
|
+
fn: async (runtime: IAgentRuntime) => {
|
|
106
99
|
// Test the character name
|
|
107
100
|
if (runtime.character.name !== 'Eliza') {
|
|
108
101
|
throw new Error(
|
|
@@ -125,7 +118,7 @@ export const StarterPluginTestSuite: TestSuite = {
|
|
|
125
118
|
*/
|
|
126
119
|
{
|
|
127
120
|
name: 'should_have_hello_world_action',
|
|
128
|
-
fn: async (runtime) => {
|
|
121
|
+
fn: async (runtime: IAgentRuntime) => {
|
|
129
122
|
// Access actions through runtime.actions instead of getPlugin
|
|
130
123
|
const actionExists = runtime.actions?.some((a) => a.name === 'HELLO_WORLD');
|
|
131
124
|
if (!actionExists) {
|
|
@@ -147,7 +140,7 @@ export const StarterPluginTestSuite: TestSuite = {
|
|
|
147
140
|
*/
|
|
148
141
|
{
|
|
149
142
|
name: 'hello_world_action_test',
|
|
150
|
-
fn: async (runtime) => {
|
|
143
|
+
fn: async (runtime: IAgentRuntime) => {
|
|
151
144
|
// Create a test message asking the agent to say hello
|
|
152
145
|
const testMessage: Memory = {
|
|
153
146
|
entityId: '12345678-1234-1234-1234-123456789012' as UUID,
|
|
@@ -215,7 +208,7 @@ export const StarterPluginTestSuite: TestSuite = {
|
|
|
215
208
|
*/
|
|
216
209
|
{
|
|
217
210
|
name: 'hello_world_provider_test',
|
|
218
|
-
fn: async (runtime) => {
|
|
211
|
+
fn: async (runtime: IAgentRuntime) => {
|
|
219
212
|
// Create a test message
|
|
220
213
|
const testMessage: Memory = {
|
|
221
214
|
entityId: '12345678-1234-1234-1234-123456789012' as UUID,
|
|
@@ -258,7 +251,7 @@ export const StarterPluginTestSuite: TestSuite = {
|
|
|
258
251
|
*/
|
|
259
252
|
{
|
|
260
253
|
name: 'starter_service_test',
|
|
261
|
-
fn: async (runtime) => {
|
|
254
|
+
fn: async (runtime: IAgentRuntime) => {
|
|
262
255
|
// Get the service from the runtime
|
|
263
256
|
const service = runtime.getService('starter');
|
|
264
257
|
if (!service) {
|
|
@@ -287,7 +280,7 @@ export const StarterPluginTestSuite: TestSuite = {
|
|
|
287
280
|
* ```typescript
|
|
288
281
|
* {
|
|
289
282
|
* name: 'your_test_name',
|
|
290
|
-
* fn: async (runtime) => {
|
|
283
|
+
* fn: async (runtime: IAgentRuntime) => {
|
|
291
284
|
* // Setup: Create any test data needed
|
|
292
285
|
*
|
|
293
286
|
* // Action: Perform the operation you want to test
|
|
@@ -13,7 +13,6 @@ import type {
|
|
|
13
13
|
} from '@elizaos/core';
|
|
14
14
|
import { ModelType, Service, logger } from '@elizaos/core';
|
|
15
15
|
import { z } from 'zod';
|
|
16
|
-
import { StarterPluginTestSuite } from './tests';
|
|
17
16
|
|
|
18
17
|
/**
|
|
19
18
|
* Defines the configuration schema for a plugin, including the validation rules for the plugin name.
|
|
@@ -89,7 +88,7 @@ const helloWorldAction: Action = {
|
|
|
89
88
|
},
|
|
90
89
|
};
|
|
91
90
|
} catch (error) {
|
|
92
|
-
logger.error('Error in HelloWorld action:'
|
|
91
|
+
logger.error({ error }, 'Error in HelloWorld action:');
|
|
93
92
|
return {
|
|
94
93
|
success: false,
|
|
95
94
|
error: error instanceof Error ? error : new Error(String(error)),
|
|
@@ -245,35 +244,34 @@ export const starterPlugin: Plugin = {
|
|
|
245
244
|
async (params) => {
|
|
246
245
|
logger.debug('MESSAGE_RECEIVED event received');
|
|
247
246
|
// print the keys
|
|
248
|
-
logger.debug(Object.keys(params));
|
|
247
|
+
logger.debug({ keys: Object.keys(params) }, 'MESSAGE_RECEIVED param keys');
|
|
249
248
|
},
|
|
250
249
|
],
|
|
251
250
|
VOICE_MESSAGE_RECEIVED: [
|
|
252
251
|
async (params) => {
|
|
253
252
|
logger.debug('VOICE_MESSAGE_RECEIVED event received');
|
|
254
253
|
// print the keys
|
|
255
|
-
logger.debug(Object.keys(params));
|
|
254
|
+
logger.debug({ keys: Object.keys(params) }, 'VOICE_MESSAGE_RECEIVED param keys');
|
|
256
255
|
},
|
|
257
256
|
],
|
|
258
257
|
WORLD_CONNECTED: [
|
|
259
258
|
async (params) => {
|
|
260
259
|
logger.debug('WORLD_CONNECTED event received');
|
|
261
260
|
// print the keys
|
|
262
|
-
logger.debug(Object.keys(params));
|
|
261
|
+
logger.debug({ keys: Object.keys(params) }, 'WORLD_CONNECTED param keys');
|
|
263
262
|
},
|
|
264
263
|
],
|
|
265
264
|
WORLD_JOINED: [
|
|
266
265
|
async (params) => {
|
|
267
266
|
logger.debug('WORLD_JOINED event received');
|
|
268
267
|
// print the keys
|
|
269
|
-
logger.debug(Object.keys(params));
|
|
268
|
+
logger.debug({ keys: Object.keys(params) }, 'WORLD_JOINED param keys');
|
|
270
269
|
},
|
|
271
270
|
],
|
|
272
271
|
},
|
|
273
272
|
services: [StarterService],
|
|
274
273
|
actions: [helloWorldAction],
|
|
275
274
|
providers: [helloWorldProvider],
|
|
276
|
-
tests: [StarterPluginTestSuite],
|
|
277
275
|
// dependencies: ['@elizaos/plugin-knowledge'], <--- plugin dependencies go here (if requires another plugin)
|
|
278
276
|
};
|
|
279
277
|
|
|
@@ -42,23 +42,36 @@ elizaos test
|
|
|
42
42
|
|
|
43
43
|
## Testing
|
|
44
44
|
|
|
45
|
-
ElizaOS
|
|
45
|
+
ElizaOS employs a dual testing strategy:
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
1. **Component Tests** (`src/__tests__/*.test.ts`)
|
|
48
|
+
|
|
49
|
+
- Run with Bun's native test runner
|
|
50
|
+
- Fast, isolated tests using mocks
|
|
51
|
+
- Perfect for TDD and component logic
|
|
48
52
|
|
|
49
|
-
|
|
53
|
+
2. **E2E Tests** (`src/__tests__/e2e/*.e2e.ts`)
|
|
54
|
+
- Run with ElizaOS custom test runner
|
|
55
|
+
- Real runtime with actual database (PGLite)
|
|
56
|
+
- Test complete user scenarios
|
|
50
57
|
|
|
51
|
-
|
|
52
|
-
- **Integration Tests**: Test how components work together
|
|
53
|
-
- Run with: `elizaos test component`
|
|
58
|
+
### Test Structure
|
|
54
59
|
|
|
55
|
-
|
|
60
|
+
```
|
|
61
|
+
src/
|
|
62
|
+
__tests__/ # All tests live inside src
|
|
63
|
+
*.test.ts # Component tests (use Bun test runner)
|
|
64
|
+
e2e/ # E2E tests (use ElizaOS test runner)
|
|
65
|
+
project-starter.e2e.ts # E2E test suite
|
|
66
|
+
README.md # E2E testing documentation
|
|
67
|
+
index.ts # Export tests here: tests: [ProjectStarterTestSuite]
|
|
68
|
+
```
|
|
56
69
|
|
|
57
|
-
|
|
58
|
-
- Run with: `elizaos test e2e`
|
|
70
|
+
### Running Tests
|
|
59
71
|
|
|
60
|
-
-
|
|
61
|
-
|
|
72
|
+
- `elizaos test` - Run all tests (component + e2e)
|
|
73
|
+
- `elizaos test component` - Run only component tests
|
|
74
|
+
- `elizaos test e2e` - Run only E2E tests
|
|
62
75
|
|
|
63
76
|
### Writing Tests
|
|
64
77
|
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
"dist"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@elizaos/cli": "1.
|
|
32
|
-
"@elizaos/core": "1.
|
|
33
|
-
"@elizaos/plugin-bootstrap": "1.
|
|
34
|
-
"@elizaos/plugin-sql": "1.
|
|
31
|
+
"@elizaos/cli": "1.4.2",
|
|
32
|
+
"@elizaos/core": "1.4.2",
|
|
33
|
+
"@elizaos/plugin-bootstrap": "1.4.2",
|
|
34
|
+
"@elizaos/plugin-sql": "1.4.2",
|
|
35
35
|
"@tanstack/react-query": "^5.29.0",
|
|
36
36
|
"clsx": "^2.1.1",
|
|
37
37
|
"react": "^18.3.1",
|
|
@@ -107,7 +107,7 @@ describe('Actions', () => {
|
|
|
107
107
|
expect(result).toBe(true);
|
|
108
108
|
} catch (e) {
|
|
109
109
|
error = e as Error;
|
|
110
|
-
logger.error('Validate function error:'
|
|
110
|
+
logger.error({ error: e }, 'Validate function error:');
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
documentTestResult('HELLO_WORLD action validate', result, error);
|
|
@@ -145,7 +145,7 @@ describe('Actions', () => {
|
|
|
145
145
|
expect(callbackResponse).toHaveProperty('source', 'test');
|
|
146
146
|
} catch (e) {
|
|
147
147
|
error = e as Error;
|
|
148
|
-
logger.error('Handler function error:'
|
|
148
|
+
logger.error({ error: e }, 'Handler function error:');
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
documentTestResult('HELLO_WORLD action handler', callbackResponse, error);
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# E2E Tests for Project Starter
|
|
2
|
+
|
|
3
|
+
This directory contains end-to-end tests for the ElizaOS project starter template.
|
|
4
|
+
|
|
5
|
+
## ElizaOS Testing Philosophy
|
|
6
|
+
|
|
7
|
+
ElizaOS employs a dual testing strategy:
|
|
8
|
+
|
|
9
|
+
1. **Component Tests** (`src/__tests__/*.test.ts`)
|
|
10
|
+
|
|
11
|
+
- Run with Bun's native test runner
|
|
12
|
+
- Fast, isolated tests using mocks
|
|
13
|
+
- Perfect for TDD and component logic
|
|
14
|
+
- Command: `bun test`
|
|
15
|
+
|
|
16
|
+
2. **E2E Tests** (`src/__tests__/e2e/*.e2e.ts`)
|
|
17
|
+
- Run with ElizaOS custom test runner
|
|
18
|
+
- Real runtime with actual database (PGLite)
|
|
19
|
+
- Test complete user scenarios
|
|
20
|
+
- Command: `elizaos test --type e2e`
|
|
21
|
+
|
|
22
|
+
## Overview
|
|
23
|
+
|
|
24
|
+
E2E tests run in a real ElizaOS runtime environment, allowing you to test your project's behavior as it would work in production. Unlike component tests, E2E tests provide access to a fully initialized runtime with all services, actions, and providers available.
|
|
25
|
+
|
|
26
|
+
## Test Structure
|
|
27
|
+
|
|
28
|
+
- **ProjectStarterTestSuite** - Main test suite containing comprehensive e2e tests:
|
|
29
|
+
- **Core Project Tests**
|
|
30
|
+
- `project_should_initialize_correctly` - Verifies project and runtime initialization
|
|
31
|
+
- `character_should_be_loaded_correctly` - Validates all character configuration fields
|
|
32
|
+
- **Natural Language Processing Tests**
|
|
33
|
+
- `agent_should_respond_to_greeting` - Tests basic greeting interactions
|
|
34
|
+
- `agent_should_respond_to_hello_world` - Validates specific hello world response
|
|
35
|
+
- `agent_should_respond_to_casual_greetings` - Tests various casual greeting formats
|
|
36
|
+
- `agent_should_maintain_conversation_context` - Validates context retention
|
|
37
|
+
- **Action & Provider Tests**
|
|
38
|
+
- `hello_world_action_direct_execution` - Tests direct action execution
|
|
39
|
+
- `hello_world_provider_test` - Validates provider functionality
|
|
40
|
+
- **Service & System Tests**
|
|
41
|
+
- `starter_service_test` - Tests service lifecycle and configuration
|
|
42
|
+
- `memory_system_should_store_and_retrieve_messages` - Tests memory persistence
|
|
43
|
+
- `agent_should_handle_multiple_concurrent_messages` - Tests concurrent processing
|
|
44
|
+
- `project_configuration_should_be_valid` - Validates project configuration
|
|
45
|
+
- `plugin_initialization_test` - Tests plugin system integration
|
|
46
|
+
|
|
47
|
+
## Integration with Project
|
|
48
|
+
|
|
49
|
+
E2E tests are integrated directly into your project through the main index.ts file:
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
// src/index.ts
|
|
53
|
+
import { ProjectStarterTestSuite } from './__tests__/e2e/project-starter.e2e';
|
|
54
|
+
|
|
55
|
+
export const project: Project = {
|
|
56
|
+
agents: [projectAgent],
|
|
57
|
+
tests: [ProjectStarterTestSuite], // Direct import!
|
|
58
|
+
};
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Running Tests
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# Run all tests (component + e2e)
|
|
65
|
+
elizaos test
|
|
66
|
+
|
|
67
|
+
# Run only e2e tests (slower, full integration)
|
|
68
|
+
elizaos test --type e2e
|
|
69
|
+
|
|
70
|
+
# Run only component tests (fast, for TDD)
|
|
71
|
+
bun test
|
|
72
|
+
# or
|
|
73
|
+
elizaos test --type component
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Implementation Details
|
|
77
|
+
|
|
78
|
+
1. **Direct Import**: Tests are imported directly from the e2e test file - no intermediate export file needed
|
|
79
|
+
2. **Project Integration**: The test suite is added to the project's `tests` array
|
|
80
|
+
3. **Test Discovery**: The ElizaOS test runner automatically finds and executes tests from the project's `tests` array
|
|
81
|
+
4. **Runtime Access**: Each test receives a real runtime instance with full access to:
|
|
82
|
+
- Agent character configuration
|
|
83
|
+
- Database and model access
|
|
84
|
+
- All registered plugins and services
|
|
85
|
+
- Memory and conversation history
|
|
86
|
+
|
|
87
|
+
## Key Differences from Plugin Tests
|
|
88
|
+
|
|
89
|
+
- **Export Location**: Tests are exported from the `ProjectAgent` in `src/index.ts` (not directly from `Project`)
|
|
90
|
+
- **Test Focus**: Tests focus on agent behavior and character configuration rather than plugin functionality
|
|
91
|
+
- **Project Context**: Tests have access to the full project configuration including character settings
|
|
92
|
+
|
|
93
|
+
## Writing New Tests
|
|
94
|
+
|
|
95
|
+
See the comprehensive documentation at the top of `project-starter.e2e.ts` for detailed instructions on adding new tests.
|
|
96
|
+
|
|
97
|
+
## Best Practices
|
|
98
|
+
|
|
99
|
+
1. **Test User Journeys**: Focus on complete user interactions with the agent
|
|
100
|
+
2. **Character Validation**: Ensure character properties affect agent behavior as expected
|
|
101
|
+
3. **Context Testing**: Verify the agent maintains context across conversations
|
|
102
|
+
4. **Concurrent Operations**: Test how the agent handles multiple simultaneous requests
|
|
103
|
+
5. **Configuration Validation**: Ensure all required settings are properly loaded
|