@elizaos/cli 1.3.1 → 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.
Files changed (198) hide show
  1. package/README.md +47 -1
  2. package/dist/{bun-exec-6CQHTS4F.js → bun-exec-ULMPAIQC.js} +1 -1
  3. package/dist/{chunk-2ALAPQLV.js → chunk-D3QSET5H.js} +342 -360
  4. package/dist/{chunk-FDEDLANP.js → chunk-FQYWRHLX.js} +1 -1
  5. package/dist/{chunk-RM6LUTKD.js → chunk-FSSUAWXQ.js} +3 -3
  6. package/dist/chunk-GXWWPFBO.js +39 -0
  7. package/dist/{chunk-D3Q2UZLZ.js → chunk-I4L4T7QX.js} +1 -1
  8. package/dist/{chunk-KDNV7EA5.js → chunk-SMZBJQJR.js} +1 -1
  9. package/dist/commands/agent/actions/index.d.ts +5 -0
  10. package/dist/commands/agent/actions/index.js +4 -4
  11. package/dist/commands/agent/index.d.ts +2 -2
  12. package/dist/commands/agent/index.js +4 -4
  13. package/dist/commands/create/actions/index.js +5 -5
  14. package/dist/commands/create/index.js +6 -6
  15. package/dist/commands/shared/index.d.ts +11 -28
  16. package/dist/commands/shared/index.js +7 -3
  17. package/dist/index.js +599 -483
  18. package/dist/{plugin-creator-H26ZLR6H.js → plugin-creator-TCUFII32.js} +2 -2
  19. package/dist/{registry-N626N4VG.js → registry-RF6PW3EN.js} +4 -4
  20. package/dist/templates/plugin-quick-starter/README.md +52 -10
  21. package/dist/templates/plugin-quick-starter/package.json +10 -3
  22. package/dist/templates/plugin-quick-starter/src/__tests__/e2e/README.md +140 -0
  23. package/dist/templates/plugin-quick-starter/src/__tests__/e2e/plugin-quick-starter.e2e.ts +339 -0
  24. package/dist/templates/plugin-quick-starter/src/__tests__/plugin.test.ts +537 -146
  25. package/dist/templates/plugin-quick-starter/src/__tests__/test-utils.ts +316 -115
  26. package/dist/templates/plugin-quick-starter/src/plugin.ts +20 -26
  27. package/dist/templates/plugin-starter/README.md +124 -49
  28. package/dist/templates/plugin-starter/package.json +10 -3
  29. package/dist/templates/plugin-starter/src/__tests__/e2e/README.md +44 -9
  30. package/{templates/plugin-starter/src/__tests__/e2e/starter-plugin.ts → dist/templates/plugin-starter/src/__tests__/e2e/plugin-starter.e2e.ts} +13 -20
  31. package/dist/templates/plugin-starter/src/__tests__/integration.test.ts +13 -13
  32. package/dist/templates/plugin-starter/src/__tests__/plugin.test.ts +556 -129
  33. package/dist/templates/plugin-starter/src/__tests__/test-utils.ts +347 -115
  34. package/dist/templates/plugin-starter/src/plugin.ts +21 -27
  35. package/dist/templates/project-starter/README.md +25 -12
  36. package/dist/templates/project-starter/package.json +4 -4
  37. package/dist/templates/project-starter/src/__tests__/actions.test.ts +2 -2
  38. package/dist/templates/project-starter/src/__tests__/e2e/README.md +103 -0
  39. package/dist/templates/project-starter/src/__tests__/e2e/project-starter.e2e.ts +575 -0
  40. package/dist/templates/project-starter/src/__tests__/env.test.ts +3 -1
  41. package/dist/templates/project-starter/src/__tests__/file-structure.test.ts +3 -2
  42. package/dist/templates/project-starter/src/__tests__/integration.test.ts +2 -2
  43. package/dist/templates/project-starter/src/__tests__/models.test.ts +3 -3
  44. package/dist/templates/project-starter/src/__tests__/plugin.test.ts +3 -3
  45. package/dist/templates/project-starter/src/__tests__/provider.test.ts +2 -2
  46. package/dist/templates/project-starter/src/index.ts +4 -3
  47. package/dist/templates/project-starter/src/plugin.ts +5 -5
  48. package/dist/templates/project-starter/tsup.config.ts +2 -1
  49. package/dist/templates/project-tee-starter/.dockerignore +64 -14
  50. package/dist/templates/project-tee-starter/Dockerfile +9 -5
  51. package/dist/templates/project-tee-starter/GUIDE.md +103 -42
  52. package/dist/templates/project-tee-starter/README.md +83 -24
  53. package/dist/templates/project-tee-starter/docker-compose.yaml +5 -2
  54. package/dist/templates/{plugin-starter/dist → project-tee-starter}/index.html +3 -3
  55. package/dist/templates/project-tee-starter/package.json +34 -14
  56. package/dist/templates/project-tee-starter/postcss.config.js +3 -0
  57. package/dist/templates/project-tee-starter/scripts/install-test-deps.js +52 -0
  58. package/dist/templates/project-tee-starter/scripts/test-all.sh +82 -0
  59. package/dist/templates/project-tee-starter/src/__tests__/build-order.test.ts +62 -0
  60. package/dist/templates/project-tee-starter/{__tests__ → src/__tests__}/character.test.ts +20 -18
  61. package/dist/templates/project-tee-starter/{__tests__ → src/__tests__}/config.test.ts +11 -4
  62. package/dist/templates/project-tee-starter/src/__tests__/e2e/README.md +128 -0
  63. package/dist/templates/project-tee-starter/src/__tests__/e2e/project-tee-starter.e2e.ts +280 -0
  64. package/dist/templates/project-tee-starter/{__tests__ → src/__tests__}/env.test.ts +3 -2
  65. package/{templates/project-tee-starter → dist/templates/project-tee-starter/src}/__tests__/error-handling.test.ts +2 -2
  66. package/{templates/project-tee-starter → dist/templates/project-tee-starter/src}/__tests__/events.test.ts +1 -1
  67. package/{templates/project-tee-starter → dist/templates/project-tee-starter/src}/__tests__/file-structure.test.ts +16 -5
  68. package/dist/templates/project-tee-starter/src/__tests__/frontend.test.ts +459 -0
  69. package/{templates/project-tee-starter → dist/templates/project-tee-starter/src}/__tests__/integration.test.ts +2 -2
  70. package/dist/templates/project-tee-starter/{__tests__ → src/__tests__}/models.test.ts +1 -1
  71. package/dist/templates/project-tee-starter/{__tests__ → src/__tests__}/plugin.test.ts +5 -3
  72. package/{templates/project-tee-starter → dist/templates/project-tee-starter/src}/__tests__/provider.test.ts +2 -2
  73. package/dist/templates/project-tee-starter/src/__tests__/routes.test.ts +30 -0
  74. package/dist/templates/project-tee-starter/src/__tests__/tee-validation.test.ts +295 -0
  75. package/{templates/project-tee-starter → dist/templates/project-tee-starter/src}/__tests__/test-utils.ts +2 -2
  76. package/dist/templates/project-tee-starter/src/__tests__/vite-config-utils.ts +51 -0
  77. package/dist/templates/project-tee-starter/src/frontend/index.css +106 -0
  78. package/dist/templates/project-tee-starter/src/frontend/index.html +20 -0
  79. package/dist/templates/project-tee-starter/src/frontend/index.tsx +370 -0
  80. package/dist/templates/project-tee-starter/src/frontend/panels.tsx +17 -0
  81. package/dist/templates/project-tee-starter/src/frontend/utils.ts +6 -0
  82. package/dist/templates/project-tee-starter/src/index.ts +8 -6
  83. package/dist/templates/project-tee-starter/src/plugin.ts +223 -61
  84. package/dist/templates/project-tee-starter/tailwind.config.js +62 -0
  85. package/dist/templates/project-tee-starter/tsconfig.build.json +2 -2
  86. package/dist/templates/project-tee-starter/tsconfig.json +8 -5
  87. package/dist/templates/project-tee-starter/tsup.config.ts +3 -2
  88. package/dist/templates/project-tee-starter/vite.config.ts +39 -0
  89. package/dist/url-utils-CKc_Ebt_.d.ts +35 -0
  90. package/dist/{utils-H66532NB.js → utils-5HPZSIF6.js} +4 -4
  91. package/package.json +7 -6
  92. package/templates/plugin-quick-starter/README.md +52 -10
  93. package/templates/plugin-quick-starter/package.json +10 -3
  94. package/templates/plugin-quick-starter/src/__tests__/e2e/README.md +140 -0
  95. package/templates/plugin-quick-starter/src/__tests__/e2e/plugin-quick-starter.e2e.ts +339 -0
  96. package/templates/plugin-quick-starter/src/__tests__/plugin.test.ts +537 -146
  97. package/templates/plugin-quick-starter/src/__tests__/test-utils.ts +316 -115
  98. package/templates/plugin-quick-starter/src/plugin.ts +20 -26
  99. package/templates/plugin-starter/README.md +124 -49
  100. package/templates/plugin-starter/package.json +10 -3
  101. package/templates/plugin-starter/src/__tests__/e2e/README.md +44 -9
  102. package/{dist/templates/plugin-starter/src/__tests__/e2e/starter-plugin.ts → templates/plugin-starter/src/__tests__/e2e/plugin-starter.e2e.ts} +13 -20
  103. package/templates/plugin-starter/src/__tests__/integration.test.ts +13 -13
  104. package/templates/plugin-starter/src/__tests__/plugin.test.ts +556 -129
  105. package/templates/plugin-starter/src/__tests__/test-utils.ts +347 -115
  106. package/templates/plugin-starter/src/plugin.ts +21 -27
  107. package/templates/project-starter/README.md +25 -12
  108. package/templates/project-starter/package.json +4 -4
  109. package/templates/project-starter/src/__tests__/actions.test.ts +2 -2
  110. package/templates/project-starter/src/__tests__/e2e/README.md +103 -0
  111. package/templates/project-starter/src/__tests__/e2e/project-starter.e2e.ts +575 -0
  112. package/templates/project-starter/src/__tests__/env.test.ts +3 -1
  113. package/templates/project-starter/src/__tests__/file-structure.test.ts +3 -2
  114. package/templates/project-starter/src/__tests__/integration.test.ts +2 -2
  115. package/templates/project-starter/src/__tests__/models.test.ts +3 -3
  116. package/templates/project-starter/src/__tests__/plugin.test.ts +3 -3
  117. package/templates/project-starter/src/__tests__/provider.test.ts +2 -2
  118. package/templates/project-starter/src/index.ts +4 -3
  119. package/templates/project-starter/src/plugin.ts +5 -5
  120. package/templates/project-starter/tsup.config.ts +2 -1
  121. package/templates/project-tee-starter/.dockerignore +64 -14
  122. package/templates/project-tee-starter/Dockerfile +9 -5
  123. package/templates/project-tee-starter/GUIDE.md +103 -42
  124. package/templates/project-tee-starter/README.md +83 -24
  125. package/templates/project-tee-starter/docker-compose.yaml +5 -2
  126. package/templates/{plugin-starter/dist → project-tee-starter}/index.html +3 -3
  127. package/templates/project-tee-starter/package.json +34 -14
  128. package/templates/project-tee-starter/postcss.config.js +3 -0
  129. package/templates/project-tee-starter/scripts/install-test-deps.js +52 -0
  130. package/templates/project-tee-starter/scripts/test-all.sh +82 -0
  131. package/templates/project-tee-starter/src/__tests__/build-order.test.ts +62 -0
  132. package/templates/project-tee-starter/{__tests__ → src/__tests__}/character.test.ts +20 -18
  133. package/templates/project-tee-starter/{__tests__ → src/__tests__}/config.test.ts +11 -4
  134. package/templates/project-tee-starter/src/__tests__/e2e/README.md +128 -0
  135. package/templates/project-tee-starter/src/__tests__/e2e/project-tee-starter.e2e.ts +280 -0
  136. package/templates/project-tee-starter/{__tests__ → src/__tests__}/env.test.ts +3 -2
  137. package/{dist/templates/project-tee-starter → templates/project-tee-starter/src}/__tests__/error-handling.test.ts +2 -2
  138. package/{dist/templates/project-tee-starter → templates/project-tee-starter/src}/__tests__/events.test.ts +1 -1
  139. package/{dist/templates/project-tee-starter → templates/project-tee-starter/src}/__tests__/file-structure.test.ts +16 -5
  140. package/templates/project-tee-starter/src/__tests__/frontend.test.ts +459 -0
  141. package/{dist/templates/project-tee-starter → templates/project-tee-starter/src}/__tests__/integration.test.ts +2 -2
  142. package/templates/project-tee-starter/{__tests__ → src/__tests__}/models.test.ts +1 -1
  143. package/templates/project-tee-starter/{__tests__ → src/__tests__}/plugin.test.ts +5 -3
  144. package/{dist/templates/project-tee-starter → templates/project-tee-starter/src}/__tests__/provider.test.ts +2 -2
  145. package/templates/project-tee-starter/src/__tests__/routes.test.ts +30 -0
  146. package/templates/project-tee-starter/src/__tests__/tee-validation.test.ts +295 -0
  147. package/{dist/templates/project-tee-starter → templates/project-tee-starter/src}/__tests__/test-utils.ts +2 -2
  148. package/templates/project-tee-starter/src/__tests__/vite-config-utils.ts +51 -0
  149. package/templates/project-tee-starter/src/frontend/index.css +106 -0
  150. package/templates/project-tee-starter/src/frontend/index.html +20 -0
  151. package/templates/project-tee-starter/src/frontend/index.tsx +370 -0
  152. package/templates/project-tee-starter/src/frontend/panels.tsx +17 -0
  153. package/templates/project-tee-starter/src/frontend/utils.ts +6 -0
  154. package/templates/project-tee-starter/src/index.ts +8 -6
  155. package/templates/project-tee-starter/src/plugin.ts +223 -61
  156. package/templates/project-tee-starter/tailwind.config.js +62 -0
  157. package/templates/project-tee-starter/tsconfig.build.json +2 -2
  158. package/templates/project-tee-starter/tsconfig.json +8 -5
  159. package/templates/project-tee-starter/tsup.config.ts +3 -2
  160. package/templates/project-tee-starter/vite.config.ts +39 -0
  161. package/dist/chunk-4O6EZU37.js +0 -14
  162. package/dist/migration-guides/advanced-migration-guide.md +0 -459
  163. package/dist/migration-guides/completion-requirements.md +0 -379
  164. package/dist/migration-guides/integrated-migration-loop.md +0 -392
  165. package/dist/migration-guides/migration-guide.md +0 -712
  166. package/dist/migration-guides/prompt-and-generation-guide.md +0 -702
  167. package/dist/migration-guides/state-and-providers-guide.md +0 -544
  168. package/dist/migration-guides/testing-guide.md +0 -1021
  169. package/dist/templates/plugin-starter/dist/assets/index-CgkejLs_.css +0 -1
  170. package/dist/templates/plugin-starter/dist/assets/index-D1cHX53P.js +0 -49
  171. package/dist/templates/plugin-starter/dist/index.js +0 -387
  172. package/dist/templates/plugin-starter/dist/index.js.map +0 -1
  173. package/dist/templates/plugin-starter/src/tests.ts +0 -6
  174. package/dist/templates/project-starter/src/__tests__/e2e/index.ts +0 -14
  175. package/dist/templates/project-starter/src/__tests__/e2e/natural-language.test.ts +0 -246
  176. package/dist/templates/project-starter/src/__tests__/e2e/project.test.ts +0 -155
  177. package/dist/templates/project-starter/src/__tests__/e2e/starter-plugin.test.ts +0 -421
  178. package/dist/templates/project-tee-starter/__tests__/routes.test.ts +0 -21
  179. package/dist/templates/project-tee-starter/e2e/project.test.ts +0 -38
  180. package/dist/templates/project-tee-starter/e2e/starter-plugin.test.ts +0 -92
  181. package/templates/plugin-starter/dist/.vite/manifest.json +0 -11
  182. package/templates/plugin-starter/dist/assets/index-CgkejLs_.css +0 -1
  183. package/templates/plugin-starter/dist/assets/index-D1cHX53P.js +0 -49
  184. package/templates/plugin-starter/dist/index.d.ts +0 -14
  185. package/templates/plugin-starter/dist/index.js +0 -387
  186. package/templates/plugin-starter/dist/index.js.map +0 -1
  187. package/templates/plugin-starter/src/tests.ts +0 -6
  188. package/templates/project-starter/src/__tests__/e2e/index.ts +0 -14
  189. package/templates/project-starter/src/__tests__/e2e/natural-language.test.ts +0 -246
  190. package/templates/project-starter/src/__tests__/e2e/project.test.ts +0 -155
  191. package/templates/project-starter/src/__tests__/e2e/starter-plugin.test.ts +0 -421
  192. package/templates/project-tee-starter/__tests__/routes.test.ts +0 -21
  193. package/templates/project-tee-starter/e2e/project.test.ts +0 -38
  194. package/templates/project-tee-starter/e2e/starter-plugin.test.ts +0 -92
  195. /package/dist/templates/project-tee-starter/{__tests__ → src/__tests__}/actions.test.ts +0 -0
  196. /package/dist/templates/project-tee-starter/{__tests__ → src/__tests__}/utils/core-test-utils.ts +0 -0
  197. /package/templates/project-tee-starter/{__tests__ → src/__tests__}/actions.test.ts +0 -0
  198. /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 provides a comprehensive testing structure for plugins:
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
- - **Component Tests** (`__tests__/` directory):
42
-
43
- - **Unit Tests**: Test individual functions/classes in isolation
44
- - **Integration Tests**: Test how components work together
45
- - Run with: `elizaos test component`
46
-
47
- - **End-to-End Tests** (`__tests__/e2e/` directory):
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
- - **Running All Tests**:
54
- - `elizaos test` runs both component and e2e tests
50
+ ### Two Types of Tests
55
51
 
56
- ### Writing Tests
52
+ #### 1. Component Tests (Bun Test Runner)
57
53
 
58
- Component tests use Vitest:
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
- // Unit test example (__tests__/plugin.test.ts)
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
- E2E tests run in a real ElizaOS runtime:
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
- // E2E test example (__tests__/e2e/starter-plugin.ts)
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
- // Simulate user asking agent to say hello
88
- const testMessage = {
89
- content: { text: 'Can you say hello?' }
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
- #### Key E2E Testing Features:
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
- - **Real Runtime Environment**: Tests run with a fully initialized ElizaOS runtime
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
- #### Writing New E2E Tests:
182
+ - User scenarios
183
+ - Action execution flows
184
+ - Provider data integration
185
+ - Service lifecycle
186
+ - Plugin interactions
113
187
 
114
- 1. Add a new test object to the `tests` array in your test suite
115
- 2. Each test receives the runtime instance as a parameter
116
- 3. Throw errors to indicate test failures (no assertion library needed)
117
- 4. See the comprehensive documentation in `__tests__/e2e/starter-plugin.ts` for detailed examples
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 utilities in `__tests__/test-utils.ts` provide mock objects and setup functions to simplify writing component tests.
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.3.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.2.10",
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",
@@ -64,6 +64,7 @@
64
64
  "dev": "elizaos dev",
65
65
  "build": "tsc --noEmit && vite build && tsup",
66
66
  "lint": "prettier --write ./src",
67
+ "postinstall": "node -e \"const fs=require('fs');const path=require('path');const zodPath=path.join('node_modules','zod');if(fs.existsSync(zodPath)){fs.writeFileSync(path.join(zodPath,'v3.js'),'module.exports=require(\\\"./lib/index.js\\\");');fs.writeFileSync(path.join(zodPath,'v3.d.ts'),'export * from \\\"./lib/index\\\";');}\" || true",
67
68
  "test:component": "bun run test:install && bun test",
68
69
  "test:e2e": "bun run test:install && bun test",
69
70
  "test:e2e:manual": "bun run test:install && node scripts/test-e2e-manual.js",
@@ -77,7 +78,13 @@
77
78
  "access": "public"
78
79
  },
79
80
  "resolutions": {
80
- "zod": "3.24.2"
81
+ "// Note": "langchain 0.3.30 fixes @langchain/core zod/v3 import issues",
82
+ "zod": "3.24.2",
83
+ "langchain": "0.3.30",
84
+ "@langchain/core": "0.3.30"
85
+ },
86
+ "overrides": {
87
+ "@langchain/core": "0.3.30"
81
88
  },
82
89
  "agentConfig": {
83
90
  "pluginType": "elizaos:plugin:1.0.0",
@@ -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
- npm test
54
+ elizaos test
23
55
 
24
- # Run only e2e tests
25
- npm run test:e2e
56
+ # Run only e2e tests (slower, full integration)
57
+ elizaos test --type e2e
26
58
 
27
- # Run only component tests
28
- npm run test:component
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. **Test Export**: Tests are exported through `src/tests.ts` to be included in the plugin build
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. **Runtime Access**: Each test receives a real runtime instance with full access to:
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-plugin.ts` for detailed instructions on adding new tests.
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 { type Content, type HandlerCallback } from '@elizaos/core';
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
@@ -1,4 +1,4 @@
1
- import { describe, expect, it, spyOn, beforeEach, afterAll, beforeAll } from 'bun:test';
1
+ import { describe, expect, it, beforeEach, afterAll, beforeAll } from 'bun:test';
2
2
  import { starterPlugin, StarterService } from '../index';
3
3
  import { createMockRuntime, setupLoggerSpies, MockRuntime } from './test-utils';
4
4
  import { HandlerCallback, IAgentRuntime, Memory, State, UUID, logger } from '@elizaos/core';
@@ -33,15 +33,15 @@ describe('Integration: HelloWorld Action with StarterService', () => {
33
33
  };
34
34
 
35
35
  // Create a mock runtime with a spied getService method
36
- const getServiceImpl = (serviceType) => {
36
+ const getServiceImpl = (serviceType: string) => {
37
37
  if (serviceType === 'starter') {
38
- return mockService;
38
+ return mockService as any;
39
39
  }
40
40
  return null;
41
41
  };
42
42
 
43
43
  mockRuntime = createMockRuntime({
44
- getService: getServiceImpl,
44
+ getService: getServiceImpl as any,
45
45
  });
46
46
  });
47
47
 
@@ -70,8 +70,8 @@ describe('Integration: HelloWorld Action with StarterService', () => {
70
70
  };
71
71
 
72
72
  // Create a mock callback to capture the response
73
- const callbackCalls = [];
74
- const callbackFn = (...args) => {
73
+ const callbackCalls: any[] = [];
74
+ const callbackFn = (...args: any[]) => {
75
75
  callbackCalls.push(args);
76
76
  };
77
77
 
@@ -88,10 +88,9 @@ describe('Integration: HelloWorld Action with StarterService', () => {
88
88
  // Verify the callback was called with expected response
89
89
  expect(callbackCalls.length).toBeGreaterThan(0);
90
90
  if (callbackCalls.length > 0) {
91
- expect(callbackCalls[0][0]).toMatchObject({
92
- text: 'hello world!',
93
- actions: ['HELLO_WORLD'],
94
- });
91
+ expect(callbackCalls[0][0].text).toBe('Hello world!');
92
+ expect(callbackCalls[0][0].actions).toEqual(['HELLO_WORLD']);
93
+ expect(callbackCalls[0][0].source).toBe('test');
95
94
  }
96
95
 
97
96
  // Get the service to ensure integration
@@ -107,9 +106,10 @@ describe('Integration: Plugin initialization and service registration', () => {
107
106
  const mockRuntime = createMockRuntime();
108
107
 
109
108
  // Create and install a mock registerService
110
- const registerServiceCalls = [];
111
- mockRuntime.registerService = (type, service) => {
112
- registerServiceCalls.push({ type, service });
109
+ const registerServiceCalls: any[] = [];
110
+ mockRuntime.registerService = (service: any) => {
111
+ registerServiceCalls.push({ service });
112
+ return Promise.resolve();
113
113
  };
114
114
 
115
115
  // Run a minimal simulation of the plugin initialization process