@omnitron-dev/testing 0.1.3 → 0.3.0

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 (65) hide show
  1. package/dist/async/events.js.map +1 -1
  2. package/dist/async/retry.js.map +1 -1
  3. package/dist/async/wait.js.map +1 -1
  4. package/dist/docker/database-manager.js.map +1 -1
  5. package/dist/docker/docker-test-manager.d.ts +8 -0
  6. package/dist/docker/docker-test-manager.js +194 -45
  7. package/dist/docker/docker-test-manager.js.map +1 -1
  8. package/dist/docker/redis-manager.js +24 -50
  9. package/dist/docker/redis-manager.js.map +1 -1
  10. package/dist/errors.js.map +1 -1
  11. package/dist/index.d.ts +1 -1
  12. package/dist/runtime/bun-adapter.d.ts +23 -1
  13. package/dist/runtime/bun-adapter.js +3 -0
  14. package/dist/runtime/bun-adapter.js.map +1 -1
  15. package/dist/runtime/deno-adapter.d.ts +72 -16
  16. package/dist/runtime/deno-adapter.js +79 -77
  17. package/dist/runtime/deno-adapter.js.map +1 -1
  18. package/dist/runtime/node-adapter.d.ts +14 -2
  19. package/dist/titan/database/database-testing.module.d.ts +1 -1
  20. package/dist/titan/database/database-testing.module.js.map +1 -1
  21. package/dist/titan/database/test-utilities.d.ts +1 -1
  22. package/dist/titan/database/test-utilities.js +1 -1
  23. package/dist/titan/database/test-utilities.js.map +1 -1
  24. package/dist/titan/index.d.ts +2 -2
  25. package/dist/titan/index.js +1 -1
  26. package/dist/titan/index.js.map +1 -1
  27. package/dist/titan/nexus/mock-provider.js.map +1 -1
  28. package/dist/titan/nexus/test-container.js.map +1 -1
  29. package/dist/titan/nexus/test-utilities.js.map +1 -1
  30. package/dist/titan/pm/mock-process-spawner.js.map +1 -1
  31. package/dist/titan/pm/mock-spawner.js.map +1 -1
  32. package/dist/titan/pm/test-process-manager.js.map +1 -1
  33. package/dist/titan/redis-test-utils.d.ts +6 -0
  34. package/dist/titan/redis-test-utils.js +29 -0
  35. package/dist/titan/redis-test-utils.js.map +1 -1
  36. package/dist/titan/test-application.js.map +1 -1
  37. package/dist/titan/test-fixtures.js.map +1 -1
  38. package/dist/titan/test-mocks.js.map +1 -1
  39. package/dist/titan/test-module.js.map +1 -1
  40. package/package.json +37 -30
  41. package/src/docker/a-port-the-network-could-reach.spec.ts +66 -0
  42. package/src/docker/docker-orphan-reaper.spec.ts +175 -0
  43. package/src/docker/docker-port-collision.spec.ts +97 -0
  44. package/src/docker/docker-test-manager.spec.ts +122 -0
  45. package/src/docker/docker-test-manager.ts +329 -20
  46. package/src/docker/docker-volume-cleanup.spec.ts +66 -0
  47. package/src/docker/redis-manager.ts +41 -58
  48. package/src/docker/types.ts +1 -0
  49. package/src/runtime/adapter-surface.spec.ts +83 -0
  50. package/src/runtime/bun-adapter.ts +21 -0
  51. package/src/runtime/deno-adapter.ts +149 -104
  52. package/src/titan/database/database-testing.module.ts +1 -1
  53. package/src/titan/database/test-utilities.ts +1 -1
  54. package/src/titan/index.ts +6 -1
  55. package/src/titan/nexus/test-utilities.ts +1 -0
  56. package/src/titan/pm/test-process-manager.ts +12 -2
  57. package/src/titan/redis-test-utils.ts +67 -0
  58. package/runtime/bun.d.ts +0 -2
  59. package/runtime/bun.js +0 -5
  60. package/runtime/bun.ts +0 -7
  61. package/runtime/deno.d.ts +0 -2
  62. package/runtime/deno.js +0 -4
  63. package/runtime/vitest.d.ts +0 -2
  64. package/runtime/vitest.js +0 -16
  65. package/runtime/vitest.ts +0 -7
@@ -151,13 +151,20 @@ export class RedisTestManager {
151
151
  const networkId = networkName.split('-').pop() || randomBytes(4).toString('hex');
152
152
 
153
153
  try {
154
- // Create master nodes with dynamically allocated ports
155
- for (let i = 0; i < masterCount; i++) {
156
- // Use dynamic port allocation instead of fixed basePort to avoid conflicts
157
- const port = await RedisTestManager.getDockerManager()['findAvailablePort']();
158
- allocatedPorts.push(port);
159
- const name = `redis-cluster-${networkId}-master-${i}`;
160
-
154
+ // Containers are created in PARALLEL.
155
+ //
156
+ // They were created one at a time, each waiting on a healthcheck whose
157
+ // startPeriod is 10s, so a 3-master/3-replica cluster could not finish
158
+ // in under sixty seconds of start periods alone — and the tests that
159
+ // call this allow exactly sixty. They did not fail because the machine
160
+ // was slow; they could not pass as written. Nothing orders these
161
+ // containers against each other: the cluster is formed afterwards, by
162
+ // `redis-cli --cluster create`, once they are all up.
163
+ //
164
+ // Ports are still allocated one at a time, before any container starts:
165
+ // findAvailablePort() binds, reads the port and releases, so two
166
+ // concurrent calls can be handed the same one.
167
+ const spec = (kind: 'master' | 'replica', index: number, port: number) => {
161
168
  const command = [
162
169
  'redis-server',
163
170
  '--cluster-enabled',
@@ -179,14 +186,16 @@ export class RedisTestManager {
179
186
  command.push('--masterauth', password);
180
187
  }
181
188
 
182
- const container = await RedisTestManager.getDockerManager().createContainer({
183
- name,
189
+ return {
190
+ name: `redis-cluster-${networkId}-${kind}-${index}`,
184
191
  image: 'redis:7-alpine',
185
192
  ports: { 6379: port },
186
193
  networks: [networkName],
187
194
  command: command.join(' '),
188
195
  healthcheck: {
189
- test: password ? ['CMD', 'redis-cli', '-a', password, 'ping'] : ['CMD', 'redis-cli', 'ping'],
196
+ test: password
197
+ ? (['CMD', 'redis-cli', '-a', password, 'ping'] as string[])
198
+ : (['CMD', 'redis-cli', 'ping'] as string[]),
190
199
  interval: '1s',
191
200
  timeout: '5s',
192
201
  retries: 30,
@@ -196,60 +205,34 @@ export class RedisTestManager {
196
205
  healthcheck: true,
197
206
  timeout: 60000,
198
207
  },
199
- });
208
+ };
209
+ };
200
210
 
201
- masters.push(container);
202
- nodes.push({ host: container.host, port });
211
+ const replicaCount = masterCount * replicasPerMaster;
212
+ const plan: Array<{ kind: 'master' | 'replica'; index: number; port: number }> = [];
213
+ for (let i = 0; i < masterCount; i++) {
214
+ const port = await RedisTestManager.getDockerManager()['findAvailablePort']();
215
+ allocatedPorts.push(port);
216
+ plan.push({ kind: 'master', index: i, port });
203
217
  }
204
-
205
- // Create replica nodes with dynamically allocated ports
206
- for (let i = 0; i < masterCount * replicasPerMaster; i++) {
207
- // Use dynamic port allocation
218
+ for (let i = 0; i < replicaCount; i++) {
208
219
  const port = await RedisTestManager.getDockerManager()['findAvailablePort']();
209
220
  allocatedPorts.push(port);
210
- const name = `redis-cluster-${networkId}-replica-${i}`;
211
-
212
- const command = [
213
- 'redis-server',
214
- '--cluster-enabled',
215
- 'yes',
216
- '--cluster-config-file',
217
- 'nodes.conf',
218
- '--cluster-node-timeout',
219
- '5000',
220
- '--appendonly',
221
- 'no',
222
- '--save',
223
- '',
224
- '--port',
225
- '6379',
226
- ];
227
-
228
- if (password) {
229
- command.push('--requirepass', password);
230
- command.push('--masterauth', password);
231
- }
221
+ plan.push({ kind: 'replica', index: i, port });
222
+ }
232
223
 
233
- const container = await RedisTestManager.getDockerManager().createContainer({
234
- name,
235
- image: 'redis:7-alpine',
236
- ports: { 6379: port },
237
- networks: [networkName],
238
- command: command.join(' '),
239
- healthcheck: {
240
- test: password ? ['CMD', 'redis-cli', '-a', password, 'ping'] : ['CMD', 'redis-cli', 'ping'],
241
- interval: '1s',
242
- timeout: '5s',
243
- retries: 30,
244
- startPeriod: '10s',
245
- },
246
- waitFor: {
247
- healthcheck: true,
248
- timeout: 60000,
249
- },
250
- });
224
+ const created = await Promise.all(
225
+ plan.map(async ({ kind, index, port }) => ({
226
+ kind,
227
+ port,
228
+ container: await RedisTestManager.getDockerManager().createContainer(
229
+ spec(kind, index, port) as never
230
+ ),
231
+ }))
232
+ );
251
233
 
252
- replicas.push(container);
234
+ for (const { kind, port, container } of created) {
235
+ (kind === 'master' ? masters : replicas).push(container);
253
236
  nodes.push({ host: container.host, port });
254
237
  }
255
238
 
@@ -154,6 +154,7 @@ export interface RedisClusterOptions {
154
154
  /** Network name (auto-generated if not provided) */
155
155
  network?: string;
156
156
  /** Timeout in ms for cluster to become ready (default: 120000) */
157
+ /** NOT IMPLEMENTED — read by nothing; readiness uses the manager's own wait loop. */
157
158
  readyTimeout?: number;
158
159
  /** Pre-initialization delay in ms after containers start (default: 5000) */
159
160
  preInitDelay?: number;
@@ -0,0 +1,83 @@
1
+ /**
2
+ * `loadRuntimeAdapter()` promises one surface across three runtimes. It did not
3
+ * deliver one: bun-adapter exported NOTHING (it only assigned globals) and
4
+ * deno-adapter had no `test`. So the documented `adapter.test(...)` worked on
5
+ * Node and was `undefined is not a function` on Bun — a failure that appears
6
+ * only when someone runs the suite under that runtime, which is exactly the
7
+ * moment the package exists to make cheap.
8
+ *
9
+ * bun-adapter imports `bun:test` and deno-adapter needs Deno globals, so
10
+ * neither can be imported here. The surface is therefore checked statically —
11
+ * with a control below, because a source parser that silently matches nothing
12
+ * would report perfect agreement.
13
+ */
14
+ import { readFileSync } from 'node:fs';
15
+ import { join, dirname } from 'node:path';
16
+ import { fileURLToPath } from 'node:url';
17
+
18
+ import { describe, it, expect } from 'vitest';
19
+
20
+ const HERE = dirname(fileURLToPath(import.meta.url));
21
+
22
+ /** The names every adapter must expose.
23
+ *
24
+ * `vi` is in the list because a spec doing `import { vi } from 'vitest'` fails
25
+ * to LOAD on a runtime whose adapter lacks it — the whole file is lost before a
26
+ * test runs, which is how `packages/common` had a Deno runner that could not
27
+ * execute a single one of its own specs. Deno's `vi` is built from `mockFn` and
28
+ * `fakeTimers` and covers `fn`, `spyOn` and the timer controls, not all of
29
+ * vitest. */
30
+ const SURFACE = [
31
+ 'describe',
32
+ 'it',
33
+ 'test',
34
+ 'expect',
35
+ 'beforeEach',
36
+ 'afterEach',
37
+ 'beforeAll',
38
+ 'afterAll',
39
+ 'fakeTimers',
40
+ 'vi',
41
+ ] as const;
42
+
43
+ function stripComments(src: string): string {
44
+ return src.replace(/\/\*[\s\S]*?\*\//g, '').replace(/(^|[^:])\/\/[^\n]*/g, '$1');
45
+ }
46
+
47
+ /** Exported names of a module, from its source. */
48
+ function exportedNames(file: string): Set<string> {
49
+ const src = stripComments(readFileSync(join(HERE, file), 'utf8'));
50
+ const names = new Set<string>();
51
+
52
+ // export const x / export function x / export class x
53
+ for (const m of src.matchAll(/\bexport\s+(?:async\s+)?(?:const|let|var|function|class)\s+([A-Za-z_$][\w$]*)/g)) {
54
+ names.add(m[1]!);
55
+ }
56
+ // export { a, b as c } — the alias is the exported name
57
+ for (const block of src.matchAll(/\bexport\s*\{([^}]*)\}/g)) {
58
+ for (const part of block[1]!.split(',')) {
59
+ const t = part.trim();
60
+ if (!t) continue;
61
+ const as = t.match(/\bas\s+([A-Za-z_$][\w$]*)$/);
62
+ names.add(as ? as[1]! : t);
63
+ }
64
+ }
65
+ return names;
66
+ }
67
+
68
+ describe('runtime adapter surface', () => {
69
+ it('the parser can tell present from absent', () => {
70
+ // Without this the checks below pass by finding nothing anywhere.
71
+ const node = exportedNames('node-adapter.ts');
72
+ expect(node.has('expect'), 'parser found no exports at all in node-adapter').toBe(true);
73
+ expect(node.has('definitelyNotExported')).toBe(false);
74
+ });
75
+
76
+ for (const file of ['node-adapter.ts', 'bun-adapter.ts', 'deno-adapter.ts']) {
77
+ it(`${file} exports the whole surface`, () => {
78
+ const names = exportedNames(file);
79
+ const missing = SURFACE.filter((n) => !names.has(n));
80
+ expect(missing, `${file} is missing exports that loadRuntimeAdapter() callers use`).toEqual([]);
81
+ });
82
+ }
83
+ });
@@ -125,3 +125,24 @@ if (!originalExpect.toThrowError) {
125
125
  },
126
126
  });
127
127
  }
128
+
129
+ // ─── Named exports ────────────────────────────────────────────────────────
130
+ //
131
+ // `loadRuntimeAdapter()` hands the caller this module object, so anything not
132
+ // exported here is `undefined` at their call site — not a resolution error, a
133
+ // TypeError one frame later. This file used to export NOTHING: it only assigned
134
+ // globals, so `adapter.test(...)` (the documented usage) worked on Node and
135
+ // threw on Bun. Keep this list in step with node-adapter's; the surface test in
136
+ // adapter-surface.spec.ts fails if it drifts.
137
+ export {
138
+ bunDescribe as describe,
139
+ bunTest as it,
140
+ bunTest as test,
141
+ bunExpect as expect,
142
+ bunBeforeEach as beforeEach,
143
+ bunAfterEach as afterEach,
144
+ bunBeforeAll as beforeAll,
145
+ bunAfterAll as afterAll,
146
+ };
147
+ export { fakeTimers };
148
+ export const vi = (global as any).vi;
@@ -6,9 +6,9 @@
6
6
  // @ts-expect-error - Deno specific imports
7
7
  import { FakeTime } from 'https://deno.land/std@0.208.0/testing/time.ts';
8
8
  // @ts-expect-error - Deno specific imports
9
- import { expect as denoExpect } from 'https://deno.land/x/expect@v0.3.0/mod.ts';
9
+ import { expect as denoExpect, addMatchers } from 'https://deno.land/x/expect@v0.3.0/mod.ts';
10
10
  // @ts-expect-error - Deno specific imports
11
- import { it as denoIt, describe as denoDescribe } from 'https://deno.land/std@0.208.0/testing/bdd.ts';
11
+ import { it as denoIt, describe as denoDescribe, beforeAll as denoBeforeAll, beforeEach as denoBeforeEach, afterAll as denoAfterAll, afterEach as denoAfterEach } from 'https://deno.land/std@0.208.0/testing/bdd.ts';
12
12
 
13
13
  // Polyfill for node:util inherits
14
14
  function inherits(ctor: any, superCtor: any) {
@@ -27,77 +27,34 @@ function inherits(ctor: any, superCtor: any) {
27
27
 
28
28
  // Store global state
29
29
  let fakeTime: FakeTime | null = null;
30
- const beforeEachCallbacks: Array<() => void | Promise<void>> = [];
31
- const afterEachCallbacks: Array<() => void | Promise<void>> = [];
32
- const beforeAllCallbacks: Array<() => void | Promise<void>> = [];
33
- const afterAllCallbacks: Array<() => void | Promise<void>> = [];
30
+ /**
31
+ * Lifecycle hooks and blocks delegate to std's bdd, which already scopes hooks
32
+ * to the enclosing `describe`.
33
+ *
34
+ * They used to be four module-level arrays that `it` drained by hand, so a
35
+ * `beforeEach` registered inside one `describe` ran for EVERY test declared
36
+ * afterwards — across files. Concretely: `packages/common`'s
37
+ * `timed-map.spec.ts` installs fake timers in its `beforeEach`, and every
38
+ * later test in the aggregated Deno run inherited them, so `await delay(1)` in
39
+ * a different file never resolved. The run reported all 7 suites passed and
40
+ * then exited 1 with "Promise resolution is still pending but the event loop
41
+ * has already resolved" — an exit code with no failing test attached.
42
+ *
43
+ * `beforeAll` had a second bug in the same code: the callbacks were
44
+ * snapshotted BEFORE the describe body ran, so hooks registered inside the
45
+ * body never executed at all.
46
+ */
47
+ const beforeEach = denoBeforeEach;
48
+ const afterEach = denoAfterEach;
49
+ const beforeAll = denoBeforeAll;
50
+ const afterAll = denoAfterAll;
34
51
 
35
- // Custom describe that handles lifecycle hooks
36
52
  function describe(name: string, fn: () => void) {
37
- denoDescribe(name, () => {
38
- // Clear callbacks for this describe block
39
- // Note: These are preserved for potential future use in nested describe blocks
40
- // const localBeforeEach = [...beforeEachCallbacks];
41
- // const localAfterEach = [...afterEachCallbacks];
42
- const localBeforeAll = [...beforeAllCallbacks];
43
- const localAfterAll = [...afterAllCallbacks];
44
-
45
- // Run beforeAll hooks
46
- if (localBeforeAll.length > 0) {
47
- denoIt('beforeAll', async () => {
48
- for (const cb of localBeforeAll) {
49
- await cb();
50
- }
51
- });
52
- }
53
-
54
- fn();
55
-
56
- // Run afterAll hooks
57
- if (localAfterAll.length > 0) {
58
- denoIt('afterAll', async () => {
59
- for (const cb of localAfterAll) {
60
- await cb();
61
- }
62
- });
63
- }
64
- });
53
+ denoDescribe(name, fn);
65
54
  }
66
55
 
67
- // Custom it/test that runs lifecycle hooks
68
56
  function it(name: string, fn: () => void | Promise<void>) {
69
- denoIt(name, async () => {
70
- // Run beforeEach hooks
71
- for (const cb of beforeEachCallbacks) {
72
- await cb();
73
- }
74
-
75
- try {
76
- await fn();
77
- } finally {
78
- // Run afterEach hooks
79
- for (const cb of afterEachCallbacks) {
80
- await cb();
81
- }
82
- }
83
- });
84
- }
85
-
86
- // Lifecycle hooks
87
- function beforeEach(fn: () => void | Promise<void>) {
88
- beforeEachCallbacks.push(fn);
89
- }
90
-
91
- function afterEach(fn: () => void | Promise<void>) {
92
- afterEachCallbacks.push(fn);
93
- }
94
-
95
- function beforeAll(fn: () => void | Promise<void>) {
96
- beforeAllCallbacks.push(fn);
97
- }
98
-
99
- function afterAll(fn: () => void | Promise<void>) {
100
- afterAllCallbacks.push(fn);
57
+ denoIt(name, fn);
101
58
  }
102
59
 
103
60
  // Mock function implementation
@@ -105,9 +62,14 @@ function mockFn(implementation?: (...args: any[]) => any) {
105
62
  const calls: any[][] = [];
106
63
  const results: any[] = [];
107
64
 
108
- const fn = (...args: any[]) => {
65
+ // `function`, not an arrow, and `.apply` rather than a spread call: a mock
66
+ // must forward `this`. An arrow has no own `this` to forward, so
67
+ // `map.forEach(mock, context)` — or any callback whose contract includes a
68
+ // receiver — silently ran with the wrong one, and the assertion inside the
69
+ // callback failed in a way that pointed at the code under test.
70
+ const fn = function (this: any, ...args: any[]) {
109
71
  calls.push(args);
110
- const result = implementation ? implementation(...args) : undefined;
72
+ const result = implementation ? implementation.apply(this, args) : undefined;
111
73
  results.push(result);
112
74
  return result;
113
75
  };
@@ -187,55 +149,122 @@ const fakeTimers = {
187
149
  },
188
150
  };
189
151
 
190
- // Custom expect wrapper that adds missing methods
191
- const expect = (value: any) => {
192
- const matcher = denoExpect(value);
193
-
194
- // Add missing matcher methods to the chain
195
- matcher.toBeInstanceOf = function toBeInstanceOf(constructor: any) {
196
- const pass = value instanceof constructor;
197
- if (!pass) {
198
- throw new Error(`expected ${value} to be instance of ${constructor.name}`);
199
- }
200
- return { pass };
201
- };
202
-
203
- matcher.toStrictEqual = function toStrictEqual(expected: any) {
204
- return matcher.toEqual(expected);
205
- };
152
+ /**
153
+ * Vitest-shaped mocking surface for Deno.
154
+ *
155
+ * `vi` is what specs written against vitest actually import, and its absence
156
+ * here was the last thing keeping a cross-runtime run from working at all: a
157
+ * spec doing `import { vi } from 'vitest'` fails to LOAD under Deno, taking the
158
+ * whole file with it before a single test runs. Built from the pieces this
159
+ * adapter already had — `mockFn` and `fakeTimers` — so it covers what specs in
160
+ * this monorepo use (`fn`, `spyOn`, and the four timer controls) rather than
161
+ * pretending to be all of vitest.
162
+ */
163
+ const vi = {
164
+ fn: mockFn,
165
+ mock: mockFn,
166
+ spyOn: (obj: any, method: string) => {
167
+ const original = obj[method];
168
+ const spy = mockFn(original);
169
+ obj[method] = spy;
170
+ (spy as any).mockRestore = () => {
171
+ obj[method] = original;
172
+ };
173
+ return spy;
174
+ },
175
+ isMockFunction: (fn: any) => typeof fn === 'function' && typeof (fn as any).mock !== 'undefined',
176
+ useFakeTimers: fakeTimers.useFakeTimers,
177
+ useRealTimers: fakeTimers.useRealTimers,
178
+ advanceTimersByTime: fakeTimers.advanceTimersByTime,
179
+ runAllTimers: fakeTimers.runAllTimers,
180
+ clearAllTimers: fakeTimers.clearAllTimers,
181
+ };
206
182
 
207
- matcher.toThrowError = function toThrowError(expected?: any) {
183
+ /**
184
+ * Call matchers for OUR mocks.
185
+ *
186
+ * `deno.land/x/expect` implements `toHaveBeenCalled*` only for functions made
187
+ * by its own `mock.fn`, and throws "callCount only available on mock
188
+ * functions" for anything else — so a vitest-shaped spec asserting on a
189
+ * callback failed on the matcher rather than on the behaviour. Its `mock.fn`
190
+ * is not a substitute: it drops `this`, which is the bug fixed in `mockFn`
191
+ * below.
192
+ *
193
+ * `addMatchers` is the module's supported extension point and overrides the
194
+ * built-ins. Assigning onto the object returned by `expect(...)` does not:
195
+ * tried first, and the built-in kept winning.
196
+ */
197
+ const callsOf = (v: any): any[][] => (v && v.mock && Array.isArray(v.mock.calls) ? v.mock.calls : []);
198
+ const sameArgs = (a: any[], b: any[]) =>
199
+ a.length === b.length && a.every((x, i) => Deno.inspect(x) === Deno.inspect(b[i]));
200
+
201
+ addMatchers({
202
+ toHaveBeenCalled(value: any) {
203
+ const n = callsOf(value).length;
204
+ return n > 0 ? { pass: true } : { pass: false, message: 'expected mock to have been called' };
205
+ },
206
+ toHaveBeenCalledTimes(value: any, times: number) {
207
+ const n = callsOf(value).length;
208
+ return n === times
209
+ ? { pass: true }
210
+ : { pass: false, message: `expected ${times} call(s), got ${n}` };
211
+ },
212
+ toHaveBeenCalledWith(value: any, ...expected: any[]) {
213
+ const calls = callsOf(value);
214
+ return calls.some((c) => sameArgs(c, expected))
215
+ ? { pass: true }
216
+ : { pass: false, message: `expected a call with ${Deno.inspect(expected)}; calls: ${Deno.inspect(calls)}` };
217
+ },
218
+ toHaveBeenLastCalledWith(value: any, ...expected: any[]) {
219
+ const calls = callsOf(value);
220
+ const last = calls[calls.length - 1];
221
+ return last && sameArgs(last, expected)
222
+ ? { pass: true }
223
+ : { pass: false, message: `last call was ${Deno.inspect(last)}, expected ${Deno.inspect(expected)}` };
224
+ },
225
+ // These three used to be assigned onto the object `expect(...)` returns,
226
+ // which this module ignores — `toStrictEqual` reached a spec as
227
+ // "matcher not found". Same fix, same reason: `addMatchers` is the way in.
228
+ toBeInstanceOf(value: any, constructor: any) {
229
+ return value instanceof constructor
230
+ ? { pass: true }
231
+ : { pass: false, message: `expected ${Deno.inspect(value)} to be instance of ${constructor?.name}` };
232
+ },
233
+ toStrictEqual(value: any, expected: any) {
234
+ return Deno.inspect(value) === Deno.inspect(expected)
235
+ ? { pass: true }
236
+ : { pass: false, message: `expected ${Deno.inspect(value)} to strictly equal ${Deno.inspect(expected)}` };
237
+ },
238
+ toThrowError(value: any, expected?: any) {
208
239
  let error: any;
209
240
  let thrown = false;
210
-
211
241
  try {
212
- if (typeof value === 'function') {
213
- value();
214
- }
242
+ if (typeof value === 'function') value();
215
243
  } catch (e) {
216
244
  error = e;
217
245
  thrown = true;
218
246
  }
219
-
220
- if (!thrown) {
221
- throw new Error('expected function to throw');
222
- }
223
-
247
+ if (!thrown) return { pass: false, message: 'expected function to throw' };
224
248
  if (expected !== undefined) {
225
- if (typeof expected === 'string' && !error.message.includes(expected)) {
226
- throw new Error(`expected error message to include "${expected}"`);
249
+ if (typeof expected === 'string' && !String(error?.message).includes(expected)) {
250
+ return { pass: false, message: `expected error message to include "${expected}"` };
227
251
  }
228
- if (expected instanceof RegExp && !expected.test(error.message)) {
229
- throw new Error(`expected error message to match ${expected}`);
252
+ if (expected instanceof RegExp && !expected.test(String(error?.message))) {
253
+ return { pass: false, message: `expected error message to match ${expected}` };
230
254
  }
231
255
  if (typeof expected === 'function' && !(error instanceof expected)) {
232
- throw new Error(`expected error to be instance of ${expected.name}`);
256
+ return { pass: false, message: `expected error to be instance of ${expected.name}` };
233
257
  }
234
258
  }
235
-
236
259
  return { pass: true };
237
- };
260
+ },
261
+ });
262
+
263
+ // Custom expect wrapper that adds missing methods
264
+ const expect = (value: any) => {
265
+ const matcher = denoExpect(value);
238
266
 
267
+ // Add missing matcher methods to the chain
239
268
  return matcher;
240
269
  };
241
270
 
@@ -283,4 +312,20 @@ expect.extend = (matchers: Record<string, any>) => {
283
312
  };
284
313
 
285
314
  // Export everything
286
- export { it, expect, mockFn, describe, afterAll, inherits, afterEach, beforeAll, beforeEach };
315
+ // `test` is an alias of `it`, and `fakeTimers` is part of the surface on the
316
+ // other runtimes — see the note in bun-adapter.ts. Absent names come back as
317
+ // `undefined` from `loadRuntimeAdapter()`, never as an import error.
318
+ export {
319
+ it,
320
+ it as test,
321
+ expect,
322
+ mockFn,
323
+ describe,
324
+ afterAll,
325
+ inherits,
326
+ afterEach,
327
+ beforeAll,
328
+ beforeEach,
329
+ fakeTimers,
330
+ vi,
331
+ };
@@ -781,7 +781,7 @@ export class DatabaseTestingModule {
781
781
  const module = DatabaseTestingModule.forTest(isolatedOptions);
782
782
 
783
783
  // Store service reference for cleanup
784
- // eslint-disable-next-line no-unassigned-vars -- assigned via setter by consumers
784
+
785
785
  let serviceInstance: DatabaseTestingService | undefined;
786
786
 
787
787
  // Return module with enhanced cleanup that properly disposes the service
@@ -5,7 +5,7 @@
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';
8
+ import { DockerTestManager, DatabaseTestManager, type DockerContainer } from '../../docker/index.js';
9
9
  import type { DatabaseModuleOptions } from '@omnitron-dev/titan-database';
10
10
 
11
11
  export interface DatabaseTestOptions {
@@ -30,9 +30,14 @@ export {
30
30
  cleanupRedisTestFixture,
31
31
  waitForRedis,
32
32
  createMockRedis,
33
+ resolveTestRedisEndpoint,
33
34
  RedisPerformanceTester,
34
35
  } from './redis-test-utils.js';
35
- export type { RedisTestFixtureOptions, RedisTestFixture } from './redis-test-utils.js';
36
+ export type {
37
+ RedisTestFixtureOptions,
38
+ RedisTestFixture,
39
+ TestRedisEndpoint,
40
+ } from './redis-test-utils.js';
36
41
 
37
42
  // Container Utils
38
43
  export {
@@ -54,6 +54,7 @@ export interface TestModuleConfig {
54
54
  * Test harness configuration
55
55
  */
56
56
  export interface TestHarnessConfig {
57
+ /** NOT READ — the harness never resolves or mounts this. */
57
58
  component?: Constructor<any>;
58
59
  providers?: Array<[InjectionToken<any>, ProviderDefinition<any>] | TestProvider<any>>;
59
60
  zone?: {
@@ -18,9 +18,19 @@ import { MockProcessSpawner } from './mock-process-spawner.js';
18
18
  export interface ITestProcessManagerConfig extends IProcessManagerConfig {
19
19
  /** Use mock spawner for faster tests */
20
20
  mock?: boolean;
21
- /** Control time for testing */
21
+ /**
22
+ * Control time for testing
23
+ *
24
+ * NOT IMPLEMENTED — read by nothing; no clock is installed or advanced.
25
+ */
22
26
  controlTime?: boolean;
23
- /** Record all operations for verification */
27
+ /**
28
+ * Record all operations for verification
29
+ *
30
+ * NOT READ as a toggle: recording is always on. The default object below
31
+ * sets it to `true` and nothing consults it, so setting `false` records
32
+ * anyway.
33
+ */
24
34
  recordOperations?: boolean;
25
35
  }
26
36