@sparkleideas/testing 3.0.0-alpha.10

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 (42) hide show
  1. package/README.md +547 -0
  2. package/__tests__/framework.test.ts +21 -0
  3. package/package.json +61 -0
  4. package/src/fixtures/agent-fixtures.ts +793 -0
  5. package/src/fixtures/agents.ts +212 -0
  6. package/src/fixtures/configurations.ts +491 -0
  7. package/src/fixtures/index.ts +21 -0
  8. package/src/fixtures/mcp-fixtures.ts +1030 -0
  9. package/src/fixtures/memory-entries.ts +328 -0
  10. package/src/fixtures/memory-fixtures.ts +750 -0
  11. package/src/fixtures/swarm-fixtures.ts +837 -0
  12. package/src/fixtures/tasks.ts +309 -0
  13. package/src/helpers/assertion-helpers.ts +616 -0
  14. package/src/helpers/assertions.ts +286 -0
  15. package/src/helpers/create-mock.ts +200 -0
  16. package/src/helpers/index.ts +182 -0
  17. package/src/helpers/mock-factory.ts +711 -0
  18. package/src/helpers/setup-teardown.ts +678 -0
  19. package/src/helpers/swarm-instance.ts +326 -0
  20. package/src/helpers/test-application.ts +310 -0
  21. package/src/helpers/test-utils.ts +670 -0
  22. package/src/index.ts +232 -0
  23. package/src/mocks/index.ts +29 -0
  24. package/src/mocks/mock-mcp-client.ts +723 -0
  25. package/src/mocks/mock-services.ts +793 -0
  26. package/src/regression/api-contract.ts +473 -0
  27. package/src/regression/index.ts +46 -0
  28. package/src/regression/integration-regression.ts +416 -0
  29. package/src/regression/performance-baseline.ts +356 -0
  30. package/src/regression/regression-runner.ts +339 -0
  31. package/src/regression/security-regression.ts +331 -0
  32. package/src/setup.ts +127 -0
  33. package/src/v2-compat/api-compat.test.ts +590 -0
  34. package/src/v2-compat/cli-compat.test.ts +484 -0
  35. package/src/v2-compat/compatibility-validator.ts +1072 -0
  36. package/src/v2-compat/hooks-compat.test.ts +602 -0
  37. package/src/v2-compat/index.ts +58 -0
  38. package/src/v2-compat/mcp-compat.test.ts +557 -0
  39. package/src/v2-compat/report-generator.ts +441 -0
  40. package/tmp.json +0 -0
  41. package/tsconfig.json +20 -0
  42. package/vitest.config.ts +12 -0
package/src/index.ts ADDED
@@ -0,0 +1,232 @@
1
+ /**
2
+ * @sparkleideas/testing - Testing Module
3
+ * TDD London School framework and test utilities for V3 Claude-Flow
4
+ *
5
+ * Based on ADR-008 (Vitest over Jest)
6
+ *
7
+ * @example
8
+ * // Basic test setup
9
+ * import {
10
+ * setupV3Tests,
11
+ * createMockApplication,
12
+ * agentConfigs,
13
+ * swarmConfigs,
14
+ * } from '@sparkleideas/testing';
15
+ *
16
+ * setupV3Tests();
17
+ *
18
+ * describe('MyModule', () => {
19
+ * const app = createMockApplication();
20
+ *
21
+ * it('should work', async () => {
22
+ * const agent = await app.agentLifecycle.spawn(agentConfigs.queenCoordinator);
23
+ * expect(agent.success).toBe(true);
24
+ * });
25
+ * });
26
+ */
27
+
28
+ // Test setup - Global configuration and custom matchers
29
+ export * from './setup.js';
30
+
31
+ // Helpers - Mock factories, utilities, and assertions
32
+ // Explicitly export to avoid duplicates with fixtures
33
+ export {
34
+ // create-mock.js
35
+ createMock,
36
+ createDeepMock,
37
+ createSpyMock,
38
+ createMockWithBehavior,
39
+ createRetryMock,
40
+ createSequenceMock,
41
+ InteractionRecorder,
42
+ type MockedInterface,
43
+ } from './helpers/create-mock.js';
44
+
45
+ export {
46
+ // test-application.js
47
+ createTestApplication,
48
+ type TestApplication,
49
+ type IEventBus,
50
+ type ITaskManager,
51
+ type IAgentLifecycle,
52
+ type IMemoryService,
53
+ type ISecurityService,
54
+ type ISwarmCoordinator,
55
+ } from './helpers/test-application.js';
56
+
57
+ export {
58
+ // swarm-instance.js - Only export what's not in fixtures
59
+ createSwarmTestInstance,
60
+ SwarmTestInstance,
61
+ type SwarmAgent,
62
+ } from './helpers/swarm-instance.js';
63
+
64
+ export {
65
+ // assertions.js
66
+ assertCallSequence,
67
+ assertNotCalledWith,
68
+ assertInteractionCount,
69
+ assertAllCalled,
70
+ assertNoneCalled,
71
+ assertContractCompliance,
72
+ assertTimingWithin,
73
+ assertTimingRange,
74
+ assertThrowsWithMessage,
75
+ assertEventPublished,
76
+ assertMockSequence,
77
+ assertNoSensitiveDataLogged,
78
+ assertPerformanceTarget,
79
+ } from './helpers/assertions.js';
80
+
81
+ export {
82
+ // test-utils.js
83
+ waitFor,
84
+ waitUntilChanged,
85
+ retry,
86
+ withTimeout,
87
+ sleep,
88
+ createDeferred,
89
+ parallelLimit,
90
+ measureTime,
91
+ createMockClock,
92
+ createTestEmitter,
93
+ createCallSpy,
94
+ createMockStream,
95
+ collectStream,
96
+ generateTestId,
97
+ createTestContext,
98
+ expectToReject,
99
+ createTrackedMock,
100
+ TimeoutError,
101
+ type WaitForOptions,
102
+ type WaitUntilChangedOptions,
103
+ type RetryOptions,
104
+ type Deferred,
105
+ type MockClock,
106
+ type TestEmitter,
107
+ type CallSpy,
108
+ type MockStreamOptions,
109
+ type TestContext,
110
+ type TrackedMock,
111
+ } from './helpers/test-utils.js';
112
+
113
+ export {
114
+ // mock-factory.js - Only non-duplicate exports
115
+ createMockEventBus,
116
+ createMockTaskManager,
117
+ createMockAgentLifecycle,
118
+ createMockMemoryService,
119
+ createMockSecurityService,
120
+ createMockSwarmCoordinator,
121
+ createMockMCPClient,
122
+ createMockLogger,
123
+ createMockApplication,
124
+ resetMockApplication,
125
+ type MockApplication,
126
+ type ILogger,
127
+ type IMCPClient,
128
+ type DomainEvent,
129
+ type EventHandler,
130
+ type Task,
131
+ type TaskFilters,
132
+ type TerminateOptions,
133
+ type AgentFilters,
134
+ type AgentHealthCheck,
135
+ type MemoryStats,
136
+ type IndexConfig,
137
+ type InputValidationOptions,
138
+ type ExecuteOptions,
139
+ type ExecuteResult,
140
+ } from './helpers/mock-factory.js';
141
+
142
+ export {
143
+ // assertion-helpers.js
144
+ assertCalledWithPattern,
145
+ assertEventOrder,
146
+ assertEventNotPublished,
147
+ assertMocksCalledInOrder,
148
+ assertCalledNTimesWith,
149
+ assertCompletesWithin,
150
+ assertThrowsError,
151
+ assertNoSensitiveData,
152
+ assertMatchesSnapshot,
153
+ assertV3PerformanceTargets,
154
+ assertValidDomainObject,
155
+ assertOnlyCalledWithAllowed,
156
+ assertPartialOrder,
157
+ assertAllPass,
158
+ assertNonePass,
159
+ assertSameElements,
160
+ assertMockReturnsSequence,
161
+ assertValidStateTransition,
162
+ assertRetryPattern,
163
+ assertDependencyInjected,
164
+ registerCustomMatchers,
165
+ type SnapshotOptions,
166
+ type V3PerformanceMetrics,
167
+ type RetryPatternOptions,
168
+ } from './helpers/assertion-helpers.js';
169
+
170
+ export {
171
+ // setup-teardown.js
172
+ createSetupContext,
173
+ getGlobalContext,
174
+ resetGlobalContext,
175
+ configureTestEnvironment,
176
+ createTestSuite,
177
+ createTestScope,
178
+ createInMemoryDatabaseHelper,
179
+ createNetworkTestHelper,
180
+ createInMemoryFileSystemHelper,
181
+ createPerformanceTestHelper,
182
+ setupV3Tests,
183
+ flushPromises,
184
+ withTestTimeout,
185
+ type SetupContext,
186
+ type CleanupFunction,
187
+ type Disposable,
188
+ type TestEnvironmentConfig,
189
+ type TestSuiteHelpers,
190
+ type TestScope,
191
+ type DatabaseTestHelper,
192
+ type NetworkTestHelper,
193
+ type MockFetchResponse,
194
+ type FileSystemTestHelper,
195
+ type PerformanceTestHelper,
196
+ type V3TestConfig,
197
+ } from './helpers/setup-teardown.js';
198
+
199
+ // Fixtures - Pre-defined test data (canonical source for shared types)
200
+ export * from './fixtures/index.js';
201
+
202
+ // Mocks - Service mock implementations (explicit to avoid duplicates)
203
+ export {
204
+ MockAgentDB,
205
+ MockSwarmCoordinator,
206
+ MockSwarmAgent,
207
+ MockMemoryService,
208
+ MockEventBus,
209
+ MockSecurityService,
210
+ createMockServices,
211
+ resetMockServices,
212
+ type MockServiceBundle,
213
+ } from './mocks/mock-services.js';
214
+
215
+ export {
216
+ MockMCPClient,
217
+ MockMCPServer,
218
+ MockMCPConnection,
219
+ MCPClientError,
220
+ createStandardMockMCPClient,
221
+ createFailingMockMCPClient,
222
+ createSlowMockMCPClient,
223
+ } from './mocks/mock-mcp-client.js';
224
+
225
+ // Regression Testing - Prevent capability degradation
226
+ export * from './regression/index.js';
227
+
228
+ // V2 Compatibility Testing - Validate backward compatibility
229
+ export * from './v2-compat/index.js';
230
+
231
+ // Re-export commonly used Vitest utilities
232
+ export { vi, expect, describe, it, test, beforeEach, afterEach, beforeAll, afterAll } from 'vitest';
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @sparkleideas/testing - Mocks Index
3
+ *
4
+ * Central export for all mock implementations
5
+ */
6
+
7
+ // Mock services
8
+ export {
9
+ MockAgentDB,
10
+ MockSwarmCoordinator,
11
+ MockSwarmAgent,
12
+ MockMemoryService,
13
+ MockEventBus,
14
+ MockSecurityService,
15
+ createMockServices,
16
+ resetMockServices,
17
+ type MockServiceBundle,
18
+ } from './mock-services.js';
19
+
20
+ // Mock MCP client and server
21
+ export {
22
+ MockMCPClient,
23
+ MockMCPServer,
24
+ MockMCPConnection,
25
+ MCPClientError,
26
+ createStandardMockMCPClient,
27
+ createFailingMockMCPClient,
28
+ createSlowMockMCPClient,
29
+ } from './mock-mcp-client.js';