@omnitron-dev/testing 0.4.5 → 0.4.8

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 (116) hide show
  1. package/README.md +36 -0
  2. package/dist/async/events.js.map +1 -1
  3. package/dist/async/retry.js.map +1 -1
  4. package/dist/async/wait.js.map +1 -1
  5. package/dist/docker/database-manager.js +13 -15
  6. package/dist/docker/database-manager.js.map +1 -1
  7. package/dist/docker/docker-test-manager.d.ts +12 -3
  8. package/dist/docker/docker-test-manager.js +286 -255
  9. package/dist/docker/docker-test-manager.js.map +1 -1
  10. package/dist/docker/redis-manager.js +68 -94
  11. package/dist/docker/redis-manager.js.map +1 -1
  12. package/dist/docker/types.d.ts +7 -2
  13. package/dist/env.d.ts +11 -0
  14. package/dist/env.js +21 -0
  15. package/dist/env.js.map +1 -0
  16. package/dist/errors.js.map +1 -1
  17. package/dist/helpers/assertions.js +3 -3
  18. package/dist/helpers/assertions.js.map +1 -1
  19. package/dist/index.d.ts +1 -1
  20. package/dist/runtime/bun-adapter.d.ts +23 -1
  21. package/dist/runtime/bun-adapter.js +14 -1
  22. package/dist/runtime/bun-adapter.js.map +1 -1
  23. package/dist/runtime/deno-adapter.d.ts +72 -15
  24. package/dist/runtime/deno-adapter.js +93 -78
  25. package/dist/runtime/deno-adapter.js.map +1 -1
  26. package/dist/runtime/node-adapter.d.ts +15 -3
  27. package/dist/runtime/node-adapter.js +1 -1
  28. package/dist/runtime/node-adapter.js.map +1 -1
  29. package/dist/runtime/test-adapter.d.ts +1 -1
  30. package/dist/runtime/test-adapter.js +12 -14
  31. package/dist/runtime/test-adapter.js.map +1 -1
  32. package/dist/titan/database/database-testing.module.d.ts +7 -6
  33. package/dist/titan/database/database-testing.module.js +39 -18
  34. package/dist/titan/database/database-testing.module.js.map +1 -1
  35. package/dist/titan/database/index.d.ts +1 -1
  36. package/dist/titan/database/index.js +1 -1
  37. package/dist/titan/database/index.js.map +1 -1
  38. package/dist/titan/database/test-utilities.d.ts +2 -2
  39. package/dist/titan/database/test-utilities.js +3 -2
  40. package/dist/titan/database/test-utilities.js.map +1 -1
  41. package/dist/titan/index.d.ts +4 -4
  42. package/dist/titan/index.js +3 -3
  43. package/dist/titan/index.js.map +1 -1
  44. package/dist/titan/nexus/mock-provider.js +6 -6
  45. package/dist/titan/nexus/mock-provider.js.map +1 -1
  46. package/dist/titan/nexus/test-container.js +10 -10
  47. package/dist/titan/nexus/test-container.js.map +1 -1
  48. package/dist/titan/nexus/test-utilities.js +9 -9
  49. package/dist/titan/nexus/test-utilities.js.map +1 -1
  50. package/dist/titan/pm/mock-process-spawner.d.ts +4 -3
  51. package/dist/titan/pm/mock-process-spawner.js +33 -14
  52. package/dist/titan/pm/mock-process-spawner.js.map +1 -1
  53. package/dist/titan/pm/mock-spawner.d.ts +2 -1
  54. package/dist/titan/pm/mock-spawner.js +3 -1
  55. package/dist/titan/pm/mock-spawner.js.map +1 -1
  56. package/dist/titan/pm/test-process-manager.d.ts +4 -4
  57. package/dist/titan/pm/test-process-manager.js +7 -3
  58. package/dist/titan/pm/test-process-manager.js.map +1 -1
  59. package/dist/titan/redis-test-utils.d.ts +8 -2
  60. package/dist/titan/redis-test-utils.js +147 -92
  61. package/dist/titan/redis-test-utils.js.map +1 -1
  62. package/dist/titan/test-application.d.ts +1 -1
  63. package/dist/titan/test-application.js +1 -1
  64. package/dist/titan/test-application.js.map +1 -1
  65. package/dist/titan/test-fixtures.js.map +1 -1
  66. package/dist/titan/test-mocks.d.ts +12 -11
  67. package/dist/titan/test-mocks.js +49 -49
  68. package/dist/titan/test-mocks.js.map +1 -1
  69. package/dist/titan/test-module.js.map +1 -1
  70. package/package.json +66 -40
  71. package/src/async/README.md +18 -328
  72. package/src/async/events.ts +1 -1
  73. package/src/docker/a-port-the-network-could-reach.spec.ts +66 -0
  74. package/src/docker/database-manager.ts +13 -15
  75. package/src/docker/docker-orphan-reaper.spec.ts +175 -0
  76. package/src/docker/docker-port-collision.spec.ts +97 -0
  77. package/src/docker/docker-test-manager.spec.ts +122 -0
  78. package/src/docker/docker-test-manager.ts +420 -326
  79. package/src/docker/docker-volume-cleanup.spec.ts +113 -0
  80. package/src/docker/redis-cluster-creation.spec.ts +52 -0
  81. package/src/docker/redis-manager.ts +80 -115
  82. package/src/docker/types.ts +11 -4
  83. package/src/env.spec.ts +20 -0
  84. package/src/env.ts +33 -0
  85. package/src/globals.d.ts +2 -2
  86. package/src/helpers/assertions.ts +3 -3
  87. package/src/index.ts +1 -1
  88. package/src/runtime/adapter-surface.spec.ts +83 -0
  89. package/src/runtime/bun-adapter.ts +36 -5
  90. package/src/runtime/deno-adapter.ts +167 -108
  91. package/src/runtime/node-adapter.ts +5 -5
  92. package/src/runtime/test-adapter.test.ts +1 -1
  93. package/src/runtime/test-adapter.ts +15 -17
  94. package/src/titan/database/database-testing.module.ts +63 -22
  95. package/src/titan/database/index.ts +2 -2
  96. package/src/titan/database/test-utilities.ts +6 -3
  97. package/src/titan/index.ts +8 -1
  98. package/src/titan/nexus/mock-provider.ts +12 -12
  99. package/src/titan/nexus/test-container.ts +12 -12
  100. package/src/titan/nexus/test-utilities.ts +13 -11
  101. package/src/titan/pm/mock-process-spawner.ts +74 -26
  102. package/src/titan/pm/mock-spawner.ts +10 -4
  103. package/src/titan/pm/test-process-manager.ts +26 -9
  104. package/src/titan/redis-test-utils.test.ts +102 -0
  105. package/src/titan/redis-test-utils.ts +191 -109
  106. package/src/titan/test-application.ts +2 -2
  107. package/src/titan/test-fixtures.ts +0 -1
  108. package/src/titan/test-mocks.ts +50 -50
  109. package/runtime/bun.d.ts +0 -2
  110. package/runtime/bun.js +0 -5
  111. package/runtime/bun.ts +0 -7
  112. package/runtime/deno.d.ts +0 -2
  113. package/runtime/deno.js +0 -4
  114. package/runtime/jest.d.ts +0 -2
  115. package/runtime/jest.js +0 -16
  116. package/runtime/jest.ts +0 -7
@@ -8,10 +8,9 @@
8
8
  import { DynamicModule, IModule } from '@omnitron-dev/titan/nexus';
9
9
  import { Module, Injectable, Inject } from '@omnitron-dev/titan/decorators';
10
10
  import { Kysely, Transaction, sql } from 'kysely';
11
- import { TitanDatabaseModule } from '@omnitron-dev/titan/module/database';
12
- import { DatabaseManager } from '@omnitron-dev/titan/module/database';
13
- import { MigrationRunner } from '@omnitron-dev/titan/module/database';
14
- import { TransactionManager } from '@omnitron-dev/titan/module/database';
11
+ import { TitanDatabaseModule } from '@omnitron-dev/titan-database';
12
+ import { DatabaseManager } from '@omnitron-dev/titan-database';
13
+ import { MigrationRunner } from '@omnitron-dev/titan-database';
15
14
  import { Errors } from '@omnitron-dev/titan/errors';
16
15
  // @kysera/testing utilities (moved from @kysera/core in 0.7.0)
17
16
  import {
@@ -29,11 +28,15 @@ import {
29
28
  } from '@kysera/testing';
30
29
  import {
31
30
  DATABASE_MANAGER,
32
- DATABASE_MIGRATION_SERVICE,
33
- DATABASE_TRANSACTION_MANAGER,
34
- DATABASE_TESTING_SERVICE,
35
- } from '@omnitron-dev/titan/module/database';
36
- import type { DatabaseModuleOptions } from '@omnitron-dev/titan/module/database';
31
+ } from '@omnitron-dev/titan-database';
32
+
33
+ // These tokens were removed from titan's public exports but are still needed
34
+ // for optional DI injection in the testing module. Using Symbol.for() ensures
35
+ // they match any other code that creates the same symbol.
36
+ const DATABASE_MIGRATION_SERVICE = Symbol.for('titan:DATABASE_MIGRATION_SERVICE');
37
+ const DATABASE_TRANSACTION_MANAGER = Symbol.for('titan:DATABASE_TRANSACTION_MANAGER');
38
+ export const DATABASE_TESTING_SERVICE = Symbol.for('titan:DATABASE_TESTING_SERVICE');
39
+ import type { DatabaseModuleOptions } from '@omnitron-dev/titan-database';
37
40
 
38
41
  export interface DatabaseTestingOptions extends Partial<DatabaseModuleOptions> {
39
42
  /**
@@ -97,7 +100,7 @@ export class DatabaseTestingService {
97
100
  @Inject(DATABASE_MANAGER) private manager: DatabaseManager,
98
101
  @Inject('DATABASE_TESTING_OPTIONS') private options: DatabaseTestingOptions,
99
102
  @Inject(DATABASE_MIGRATION_SERVICE) private migrationRunner?: MigrationRunner,
100
- @Inject(DATABASE_TRANSACTION_MANAGER) private transactionManager?: TransactionManager
103
+ @Inject(DATABASE_TRANSACTION_MANAGER) private transactionManager?: unknown
101
104
  ) {}
102
105
 
103
106
  /**
@@ -115,7 +118,7 @@ export class DatabaseTestingService {
115
118
 
116
119
  // Run migrations if enabled
117
120
  if (this.options.autoMigrate && this.migrationRunner) {
118
- await this.migrationRunner.migrate();
121
+ await this.migrationRunner.up();
119
122
  }
120
123
 
121
124
  // Seed database if enabled
@@ -130,7 +133,7 @@ export class DatabaseTestingService {
130
133
  * Setup before each test
131
134
  */
132
135
  async beforeEach(): Promise<void> {
133
- const db = await this.manager.getConnection();
136
+ const _db = await this.manager.getConnection();
134
137
 
135
138
  // Clean database if enabled
136
139
  if (this.options.autoClean) {
@@ -225,6 +228,25 @@ export class DatabaseTestingService {
225
228
  }
226
229
  }
227
230
 
231
+ /**
232
+ * Convert booleans to integers for SQLite compatibility
233
+ */
234
+ private convertBooleansForSqlite(
235
+ db: Kysely<Record<string, unknown>> | Transaction<unknown>,
236
+ data: Record<string, unknown>
237
+ ): Record<string, unknown> {
238
+ const dialect = this.getDialect(db as Kysely<Record<string, unknown>>);
239
+ if (dialect !== 'sqlite') {
240
+ return data;
241
+ }
242
+
243
+ const result: Record<string, unknown> = {};
244
+ for (const [key, value] of Object.entries(data)) {
245
+ result[key] = typeof value === 'boolean' ? (value ? 1 : 0) : value;
246
+ }
247
+ return result;
248
+ }
249
+
228
250
  /**
229
251
  * Insert seed data
230
252
  */
@@ -238,7 +260,11 @@ export class DatabaseTestingService {
238
260
  const records = Array.isArray(seed.data) ? seed.data : [seed.data];
239
261
 
240
262
  for (const record of records) {
241
- await (db as Kysely<Record<string, unknown>>).insertInto(seed.table).values(record).execute();
263
+ const convertedRecord = this.convertBooleansForSqlite(
264
+ db as Kysely<Record<string, unknown>>,
265
+ record as Record<string, unknown>
266
+ );
267
+ await (db as Kysely<Record<string, unknown>>).insertInto(seed.table).values(convertedRecord).execute();
242
268
  }
243
269
  } catch (error) {
244
270
  if (this.options.verbose) {
@@ -321,7 +347,13 @@ export class DatabaseTestingService {
321
347
  * Get database dialect
322
348
  */
323
349
  private getDialect(db: Kysely<Record<string, unknown>>): string {
324
- // Try to determine dialect from the connection
350
+ // First, try to get dialect from the DatabaseManager (most reliable)
351
+ const managerDialect = this.manager.getDialect();
352
+ if (managerDialect) {
353
+ return managerDialect;
354
+ }
355
+
356
+ // Fallback: Try to determine dialect from the Kysely instance structure
325
357
  const dbWithDialect = db as unknown as {
326
358
  dialect?: { name?: string };
327
359
  _dialect?: { name?: string };
@@ -336,7 +368,8 @@ export class DatabaseTestingService {
336
368
  if (dbWithDialect.driver?.postgres) return 'postgres';
337
369
  if (dbWithDialect.driver?.mysql) return 'mysql';
338
370
 
339
- return 'sqlite';
371
+ // If we can't determine the dialect, throw an error instead of defaulting to sqlite
372
+ throw Errors.conflict('Unable to determine database dialect. Ensure DatabaseManager is properly configured.');
340
373
  }
341
374
 
342
375
  /**
@@ -372,8 +405,8 @@ export class DatabaseTestingService {
372
405
  /**
373
406
  * Get test database connection
374
407
  */
375
- getTestConnection(): Kysely<Record<string, unknown>> | Transaction<unknown> {
376
- return (this.currentTransaction || this.manager.getConnection()) as
408
+ async getTestConnection(): Promise<Kysely<Record<string, unknown>> | Transaction<unknown>> {
409
+ return (this.currentTransaction || (await this.manager.getConnection())) as
377
410
  | Kysely<Record<string, unknown>>
378
411
  | Transaction<unknown>;
379
412
  }
@@ -386,14 +419,18 @@ export class DatabaseTestingService {
386
419
  generator: () => Partial<T> | Promise<Partial<T>>,
387
420
  count: number = 1
388
421
  ): Promise<T[]> {
389
- const db = this.getTestConnection();
422
+ const db = await this.getTestConnection();
390
423
  const results: T[] = [];
391
424
 
392
425
  for (let i = 0; i < count; i++) {
393
426
  const data = await generator();
427
+ const convertedData = this.convertBooleansForSqlite(
428
+ db as Kysely<Record<string, unknown>>,
429
+ data as Record<string, unknown>
430
+ );
394
431
  const result = await (db as Kysely<Record<string, unknown>>)
395
432
  .insertInto(table)
396
- .values(data)
433
+ .values(convertedData)
397
434
  .returningAll()
398
435
  .executeTakeFirst();
399
436
 
@@ -409,7 +446,7 @@ export class DatabaseTestingService {
409
446
  * Assert database state
410
447
  */
411
448
  async assertDatabaseHas(table: string, data: Record<string, unknown>): Promise<boolean> {
412
- const db = this.getTestConnection() as Kysely<Record<string, unknown>>;
449
+ const db = (await this.getTestConnection()) as Kysely<Record<string, unknown>>;
413
450
 
414
451
  let query = db.selectFrom(table).selectAll();
415
452
 
@@ -434,7 +471,7 @@ export class DatabaseTestingService {
434
471
  * Count records in table
435
472
  */
436
473
  async assertDatabaseCount(table: string, count: number): Promise<boolean> {
437
- const db = this.getTestConnection();
474
+ const db = await this.getTestConnection();
438
475
 
439
476
  const result = await (db as Kysely<Record<string, unknown>>)
440
477
  .selectFrom(table)
@@ -620,7 +657,7 @@ export class DatabaseTestingService {
620
657
  count: number,
621
658
  overrides?: Partial<T>
622
659
  ): Promise<T[]> {
623
- const db = this.getTestConnection() as Kysely<Record<string, unknown>>;
660
+ const db = (await this.getTestConnection()) as Kysely<Record<string, unknown>>;
624
661
  const results: T[] = [];
625
662
 
626
663
  for (let i = 0; i < count; i++) {
@@ -744,6 +781,7 @@ export class DatabaseTestingModule {
744
781
  const module = DatabaseTestingModule.forTest(isolatedOptions);
745
782
 
746
783
  // Store service reference for cleanup
784
+
747
785
  let serviceInstance: DatabaseTestingService | undefined;
748
786
 
749
787
  // Return module with enhanced cleanup that properly disposes the service
@@ -752,6 +790,9 @@ export class DatabaseTestingModule {
752
790
  get service() {
753
791
  return serviceInstance;
754
792
  },
793
+ set service(instance: DatabaseTestingService | undefined) {
794
+ serviceInstance = instance;
795
+ },
755
796
  cleanup: async () => {
756
797
  try {
757
798
  // If service was injected, clean it up
@@ -26,5 +26,5 @@ export {
26
26
  type DatabaseTestContext,
27
27
  } from './test-utilities.js';
28
28
 
29
- // Re-export DATABASE_TESTING_SERVICE constant from titan for convenience
30
- export { DATABASE_TESTING_SERVICE } from '@omnitron-dev/titan/module/database';
29
+ // Re-export DATABASE_TESTING_SERVICE from the testing module
30
+ export { DATABASE_TESTING_SERVICE } from './database-testing.module.js';
@@ -5,8 +5,8 @@
5
5
  * Falls back to SQLite when Docker is not available
6
6
  */
7
7
 
8
- import { DockerTestManager, DatabaseTestManager, type DockerContainer } from '@omnitron-dev/testing/docker';
9
- import type { DatabaseModuleOptions } from '@omnitron-dev/titan/module/database';
8
+ import { DockerTestManager, DatabaseTestManager, type DockerContainer } from '../../docker/index.js';
9
+ import type { DatabaseModuleOptions } from '@omnitron-dev/titan-database';
10
10
 
11
11
  export interface DatabaseTestOptions {
12
12
  /**
@@ -206,10 +206,13 @@ export async function createTestDatabase(options: DatabaseTestOptions = {}): Pro
206
206
  console.log('Using in-memory SQLite for testing (forced)');
207
207
  }
208
208
 
209
+ // Create unique in-memory database for each test to avoid conflicts
210
+ const uniqueId = `test_${Date.now()}_${Math.random().toString(36).substring(7)}`;
211
+
209
212
  return {
210
213
  connection: {
211
214
  dialect: 'sqlite',
212
- connection: 'file::memory:?cache=shared',
215
+ connection: `file:${uniqueId}?mode=memory&cache=shared`,
213
216
  },
214
217
  dialect: 'sqlite',
215
218
  isDocker: false,
@@ -19,6 +19,7 @@ export {
19
19
  createMockLogger,
20
20
  createMockConfigService,
21
21
  createMockRedisManager,
22
+ createMockRedisClient,
22
23
  createMockSchedulerService,
23
24
  createMockEventBus,
24
25
  } from './test-mocks.js';
@@ -29,9 +30,14 @@ export {
29
30
  cleanupRedisTestFixture,
30
31
  waitForRedis,
31
32
  createMockRedis,
33
+ resolveTestRedisEndpoint,
32
34
  RedisPerformanceTester,
33
35
  } from './redis-test-utils.js';
34
- export type { RedisTestFixtureOptions, RedisTestFixture } from './redis-test-utils.js';
36
+ export type {
37
+ RedisTestFixtureOptions,
38
+ RedisTestFixture,
39
+ TestRedisEndpoint,
40
+ } from './redis-test-utils.js';
35
41
 
36
42
  // Container Utils
37
43
  export {
@@ -115,6 +121,7 @@ export type {
115
121
  // Database Testing
116
122
  export {
117
123
  DatabaseTestingModule,
124
+ DATABASE_TESTING_SERVICE,
118
125
  DatabaseTestingService,
119
126
  createTestDatabase,
120
127
  withTestDatabase,
@@ -1,7 +1,7 @@
1
1
  import { ProviderDefinition, InjectionToken as Token } from '@omnitron-dev/titan/nexus';
2
2
 
3
- // Jest type declaration (for build compatibility)
4
- declare const jest: any;
3
+ // Vitest type declaration (for build compatibility)
4
+ declare const vi: any;
5
5
 
6
6
  /**
7
7
  * Mock provider configuration
@@ -40,12 +40,12 @@ export class MockProviderDI<T> {
40
40
  * Create an automatic mock
41
41
  */
42
42
  private createAutoMock(): T {
43
- // Create a proxy that returns jest mocks for all properties
43
+ // Create a proxy that returns vi mocks for all properties
44
44
  return new Proxy({} as any, {
45
45
  get(target, prop) {
46
46
  if (typeof prop === 'string') {
47
47
  if (!(prop in target)) {
48
- (target as any)[prop] = jest.fn();
48
+ (target as any)[prop] = vi.fn();
49
49
  }
50
50
  return (target as any)[prop];
51
51
  }
@@ -73,12 +73,12 @@ export class MockProviderDI<T> {
73
73
  }
74
74
 
75
75
  if (typeof mock === 'object' && mock !== null) {
76
- // Wrap all functions with jest spies
76
+ // Wrap all functions with vi spies
77
77
  const spy = { ...mock } as any;
78
78
 
79
79
  for (const key in spy) {
80
80
  if (typeof spy[key] === 'function') {
81
- spy[key] = jest.fn(spy[key]);
81
+ spy[key] = vi.fn(spy[key]);
82
82
  }
83
83
  }
84
84
 
@@ -107,17 +107,17 @@ export function createAutoMockProvider<T>(token: Token<T>): MockProviderDI<T> {
107
107
  }
108
108
 
109
109
  /**
110
- * Mock provider that wraps jest mocks (for test utilities)
110
+ * Mock provider that wraps vi mocks (for test utilities)
111
111
  */
112
112
  export class MockProvider {
113
113
  constructor(private mockImplementation: Record<string, any>) {
114
114
  // Copy all mock methods to the provider instance
115
115
  for (const [key, value] of Object.entries(mockImplementation)) {
116
- if (typeof value === 'function' && jest.isMockFunction && jest.isMockFunction(value)) {
116
+ if (typeof value === 'function' && vi.isMockFunction && vi.isMockFunction(value)) {
117
117
  (this as any)[key] = value;
118
118
  } else {
119
- // Wrap non-mock functions with jest.fn()
120
- (this as any)[key] = typeof value === 'function' ? jest.fn(value) : value;
119
+ // Wrap non-mock functions with vi.fn()
120
+ (this as any)[key] = typeof value === 'function' ? vi.fn(value) : value;
121
121
  }
122
122
  }
123
123
  }
@@ -138,7 +138,7 @@ export class SpyProvider {
138
138
  ) {
139
139
  for (const method of methods) {
140
140
  if (typeof this.original[method] === 'function') {
141
- const spy = jest.spyOn(this.original, method);
141
+ const spy = vi.spyOn(this.original, method);
142
142
  this.spies.set(method, spy);
143
143
 
144
144
  // Wrap to track calls manually too
@@ -183,7 +183,7 @@ export class SpyProvider {
183
183
  export class StubProvider {
184
184
  constructor(private stubs: Record<string, any>) {
185
185
  for (const [key, value] of Object.entries(stubs)) {
186
- (this as any)[key] = jest.fn().mockReturnValue(value);
186
+ (this as any)[key] = vi.fn().mockReturnValue(value);
187
187
  }
188
188
  }
189
189
  }
@@ -140,8 +140,8 @@ export class NeverCalledExpectation implements SpyExpectation {
140
140
  /**
141
141
  * Test container with testing utilities
142
142
  */
143
- // Jest types workaround for build
144
- declare const jest: any;
143
+ // Vitest types workaround for build
144
+ declare const vi: any;
145
145
 
146
146
  export class TestContainer extends Container {
147
147
  private mocks = new Map<InjectionToken<any>, any>();
@@ -236,7 +236,7 @@ export class TestContainer extends Container {
236
236
  for (const key in mock) {
237
237
  if (typeof mock[key] === 'function') {
238
238
  const original = mock[key];
239
- mock[key] = jest.fn(original);
239
+ mock[key] = vi.fn(original);
240
240
  }
241
241
  }
242
242
 
@@ -257,7 +257,7 @@ export class TestContainer extends Container {
257
257
  for (const key in wrapped) {
258
258
  if (typeof wrapped[key] === 'function') {
259
259
  const originalFn = wrapped[key];
260
- wrapped[key] = jest.fn((...args: any[]) => {
260
+ wrapped[key] = vi.fn((...args: any[]) => {
261
261
  try {
262
262
  const result = originalFn(...args);
263
263
  this.recordInteraction(token, {
@@ -288,7 +288,7 @@ export class TestContainer extends Container {
288
288
 
289
289
  for (const key in mock as any) {
290
290
  const value = (mock as any)[key];
291
- if (typeof value === 'function' && jest.isMockFunction(value)) {
291
+ if (typeof value === 'function' && vi.isMockFunction(value)) {
292
292
  spyMap.set(key, value);
293
293
  }
294
294
  }
@@ -306,7 +306,7 @@ export class TestContainer extends Container {
306
306
  throw new Error(`Cannot spy on ${String(method)} of ${String(token)}`);
307
307
  }
308
308
 
309
- const spy = jest.spyOn(instance as any, method as string);
309
+ const spy = vi.spyOn(instance as any, method as string);
310
310
 
311
311
  let spyMap = this.spies.get(token);
312
312
  if (!spyMap) {
@@ -334,7 +334,7 @@ export class TestContainer extends Container {
334
334
  stubObject[key] = value;
335
335
  } else {
336
336
  // Otherwise, create a function that returns the value
337
- stubObject[key] = jest.fn(() => value);
337
+ stubObject[key] = vi.fn(() => value);
338
338
  }
339
339
  }
340
340
 
@@ -494,7 +494,7 @@ export class TestContainer extends Container {
494
494
  if (mock && typeof mock === 'object') {
495
495
  for (const key in mock) {
496
496
  const value = mock[key];
497
- if (value && jest.isMockFunction && jest.isMockFunction(value)) {
497
+ if (value && vi.isMockFunction && vi.isMockFunction(value)) {
498
498
  value.mockReset();
499
499
  }
500
500
  }
@@ -685,7 +685,7 @@ export class TestContainer extends Container {
685
685
  this.resolvedTokens.add(token);
686
686
  }
687
687
  return result;
688
- } catch (originalError) {
688
+ } catch (_originalError) {
689
689
  // Continue to auto-mock if enabled
690
690
  }
691
691
  }
@@ -705,7 +705,7 @@ export class TestContainer extends Container {
705
705
  * Create automatic mock
706
706
  */
707
707
  private createAutoMock<T>(token: InjectionToken<any>): T {
708
- const name =
708
+ const _name =
709
709
  typeof token === 'string'
710
710
  ? token
711
711
  : typeof token === 'symbol'
@@ -717,7 +717,7 @@ export class TestContainer extends Container {
717
717
  get: (target, prop) => {
718
718
  if (typeof prop === 'string') {
719
719
  // Return a mock function for methods
720
- return jest.fn().mockImplementation((...args: any[]) => {
720
+ return vi.fn().mockImplementation((...args: any[]) => {
721
721
  this.recordInteraction(token, {
722
722
  method: prop,
723
723
  args,
@@ -792,7 +792,7 @@ export class TestContainer extends Container {
792
792
  stubObject[key] = value;
793
793
  } else {
794
794
  // Create a function that returns the stubbed value
795
- stubObject[key] = jest.fn().mockReturnValue(value);
795
+ stubObject[key] = vi.fn().mockReturnValue(value);
796
796
  }
797
797
  }
798
798
 
@@ -16,8 +16,9 @@ import {
16
16
  * Test utility functions for Nexus testing
17
17
  */
18
18
 
19
- // Jest mock function type
20
- declare const jest: any;
19
+ // Vitest mock function type (declared for type checking but may not be used)
20
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
21
+ declare const vi: any;
21
22
 
22
23
  /**
23
24
  * Test mock configuration
@@ -53,6 +54,7 @@ export interface TestModuleConfig {
53
54
  * Test harness configuration
54
55
  */
55
56
  export interface TestHarnessConfig {
57
+ /** NOT READ — the harness never resolves or mounts this. */
56
58
  component?: Constructor<any>;
57
59
  providers?: Array<[InjectionToken<any>, ProviderDefinition<any>] | TestProvider<any>>;
58
60
  zone?: {
@@ -190,7 +192,7 @@ export class IsolatedContainer extends Container {
190
192
  try {
191
193
  const value = source.resolve(token);
192
194
  isolated.register(token, { useValue: value });
193
- } catch (error) {
195
+ } catch (_error) {
194
196
  // Token not available in source
195
197
  }
196
198
  }
@@ -422,11 +424,11 @@ class RejectionExpectationImpl implements RejectionExpectation {
422
424
  throw new Error('Expected resolution to throw');
423
425
  } catch (error) {
424
426
  if (this.expectedErrorType && !(error instanceof this.expectedErrorType)) {
425
- throw new Error(`Expected ${this.expectedErrorType.name}, got ${(error as Error).constructor.name}`);
427
+ throw new Error(`Expected ${this.expectedErrorType.name}, got ${(error as Error).constructor.name}`, { cause: error });
426
428
  }
427
429
 
428
430
  if (this.expectedMessage && !(error as Error).message.includes(this.expectedMessage)) {
429
- throw new Error(`Expected error message to contain "${this.expectedMessage}"`);
431
+ throw new Error(`Expected error message to contain "${this.expectedMessage}"`, { cause: error });
430
432
  }
431
433
  }
432
434
  }
@@ -456,8 +458,8 @@ class DependencyExpectationImpl implements DependencyExpectation {
456
458
  if (this.expectedToken) {
457
459
  try {
458
460
  this.container.resolve(this.expectedToken);
459
- } catch (error) {
460
- throw new Error(`Dependency ${String(this.expectedToken)} not found`);
461
+ } catch (_error) {
462
+ throw new Error(`Dependency ${String(this.expectedToken)} not found`, { cause: _error });
461
463
  }
462
464
  }
463
465
  }
@@ -597,18 +599,18 @@ export async function assertThrows<E extends Error>(
597
599
  throw new Error('Expected function to throw');
598
600
  } catch (error) {
599
601
  if (errorType && !(error instanceof errorType)) {
600
- throw new Error(`Expected error of type ${errorType.name}, got ${(error as Error).constructor.name}`);
602
+ throw new Error(`Expected error of type ${errorType.name}, got ${(error as Error).constructor.name}`, { cause: error });
601
603
  }
602
604
 
603
605
  if (message) {
604
606
  const errorMessage = (error as Error).message;
605
607
  if (typeof message === 'string') {
606
608
  if (!errorMessage.includes(message)) {
607
- throw new Error(`Expected error message to include "${message}", got "${errorMessage}"`);
609
+ throw new Error(`Expected error message to include "${message}", got "${errorMessage}"`, { cause: error });
608
610
  }
609
611
  } else if (message instanceof RegExp) {
610
612
  if (!message.test(errorMessage)) {
611
- throw new Error(`Expected error message to match ${message}, got "${errorMessage}"`);
613
+ throw new Error(`Expected error message to match ${message}, got "${errorMessage}"`, { cause: error });
612
614
  }
613
615
  }
614
616
  }
@@ -636,7 +638,7 @@ export function verifyContainerState(
636
638
  spies?: Array<{ token: Token<any>; method: string }>;
637
639
  }
638
640
  ): void {
639
- const metadata = container.getTestMetadata();
641
+ const _metadata = container.getTestMetadata();
640
642
 
641
643
  if (expectations.registeredTokens) {
642
644
  for (const token of expectations.registeredTokens) {