@navios/core 0.7.1 → 0.9.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.
- package/CHANGELOG.md +78 -0
- package/lib/{index-DW9EPAE6.d.mts → index-D9MNh6Tx.d.mts} +534 -342
- package/lib/index-D9MNh6Tx.d.mts.map +1 -0
- package/lib/{index-pHp-dIGt.d.cts → index-Db1d3cwD.d.cts} +534 -342
- package/lib/index-Db1d3cwD.d.cts.map +1 -0
- package/lib/index.cjs +12 -3
- package/lib/index.d.cts +2 -2
- package/lib/index.d.mts +2 -2
- package/lib/index.mjs +3 -3
- package/lib/legacy-compat/index.cjs +1 -1
- package/lib/legacy-compat/index.cjs.map +1 -1
- package/lib/legacy-compat/index.d.cts +3 -3
- package/lib/legacy-compat/index.d.cts.map +1 -1
- package/lib/legacy-compat/index.d.mts +3 -3
- package/lib/legacy-compat/index.d.mts.map +1 -1
- package/lib/legacy-compat/index.mjs +1 -1
- package/lib/legacy-compat/index.mjs.map +1 -1
- package/lib/{src-QnxR5b7c.cjs → src-BRPtJ9fG.cjs} +474 -53
- package/lib/src-BRPtJ9fG.cjs.map +1 -0
- package/lib/{src-DyvCDuKO.mjs → src-Bo23RIo-.mjs} +454 -51
- package/lib/src-Bo23RIo-.mjs.map +1 -0
- package/lib/testing/index.cjs +346 -29
- package/lib/testing/index.cjs.map +1 -1
- package/lib/testing/index.d.cts +299 -63
- package/lib/testing/index.d.cts.map +1 -1
- package/lib/testing/index.d.mts +299 -63
- package/lib/testing/index.d.mts.map +1 -1
- package/lib/testing/index.mjs +347 -31
- package/lib/testing/index.mjs.map +1 -1
- package/lib/{use-guards.decorator-B6q_N0sf.cjs → use-guards.decorator-Bs8oDHOi.cjs} +29 -99
- package/lib/use-guards.decorator-Bs8oDHOi.cjs.map +1 -0
- package/lib/{use-guards.decorator-kZ3lNK8v.mjs → use-guards.decorator-CzVXuLkz.mjs} +23 -99
- package/lib/use-guards.decorator-CzVXuLkz.mjs.map +1 -0
- package/package.json +4 -4
- package/src/__tests__/controller-resolver.spec.mts +229 -0
- package/src/__tests__/controller.spec.mts +1 -1
- package/src/__tests__/testing-module.spec.mts +459 -0
- package/src/__tests__/unit-testing-module.spec.mts +424 -0
- package/src/decorators/controller.decorator.mts +29 -7
- package/src/decorators/endpoint.decorator.mts +60 -12
- package/src/decorators/module.decorator.mts +23 -5
- package/src/decorators/multipart.decorator.mts +67 -24
- package/src/decorators/stream.decorator.mts +65 -24
- package/src/interfaces/abstract-http-handler-adapter.interface.mts +31 -1
- package/src/legacy-compat/__type-tests__/legacy-decorators.spec-d.mts +2 -6
- package/src/legacy-compat/decorators/endpoint.decorator.mts +1 -1
- package/src/legacy-compat/decorators/multipart.decorator.mts +5 -5
- package/src/legacy-compat/decorators/stream.decorator.mts +5 -5
- package/src/logger/logger.service.mts +0 -2
- package/src/navios.application.mts +23 -9
- package/src/navios.environment.mts +3 -1
- package/src/navios.factory.mts +19 -18
- package/src/services/guard-runner.service.mts +46 -9
- package/src/services/index.mts +1 -0
- package/src/services/instance-resolver.service.mts +187 -0
- package/src/services/module-loader.service.mts +3 -2
- package/src/stores/request-id.store.mts +45 -3
- package/src/testing/index.mts +1 -0
- package/src/testing/testing-module.mts +255 -93
- package/src/testing/unit-testing-module.mts +298 -0
- package/src/tokens/index.mts +1 -0
- package/src/tokens/navios-options.token.mts +6 -0
- package/lib/index-DW9EPAE6.d.mts.map +0 -1
- package/lib/index-pHp-dIGt.d.cts.map +0 -1
- package/lib/src-DyvCDuKO.mjs.map +0 -1
- package/lib/src-QnxR5b7c.cjs.map +0 -1
- package/lib/use-guards.decorator-B6q_N0sf.cjs.map +0 -1
- package/lib/use-guards.decorator-kZ3lNK8v.mjs.map +0 -1
package/lib/testing/index.d.cts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ClassType, ClassTypeWithInstance, InjectionToken } from "@navios/di";
|
|
3
|
-
import
|
|
1
|
+
import { _ as NaviosApplication, nt as NaviosModule, v as NaviosApplicationOptions } from "../index-Db1d3cwD.cjs";
|
|
2
|
+
import { ClassType, ClassTypeWithInstance, InjectionToken, ScopedContainer } from "@navios/di";
|
|
3
|
+
import * as _navios_di_testing0 from "@navios/di/testing";
|
|
4
|
+
import { MethodCallRecord, MockServiceStats, ProviderConfig, TestContainer, UnitTestContainer } from "@navios/di/testing";
|
|
4
5
|
export * from "@navios/di/testing";
|
|
5
6
|
|
|
6
7
|
//#region src/testing/testing-module.d.mts
|
|
@@ -37,37 +38,90 @@ interface TestingModuleOptions extends Omit<NaviosApplicationOptions, 'container
|
|
|
37
38
|
* You can also use `overrideProvider()` method for a fluent API.
|
|
38
39
|
*/
|
|
39
40
|
overrides?: TestingModuleOverride[];
|
|
41
|
+
/**
|
|
42
|
+
* Container to use for the testing module.
|
|
43
|
+
* If not provided, a new TestContainer will be created.
|
|
44
|
+
*/
|
|
45
|
+
container?: TestContainer;
|
|
40
46
|
}
|
|
41
47
|
/**
|
|
42
48
|
* A testing-optimized wrapper around NaviosApplication.
|
|
43
49
|
* Provides utilities for setting up test environments with mock dependencies.
|
|
50
|
+
*
|
|
51
|
+
* When `init()` is called, a request scope is automatically started.
|
|
52
|
+
* This means `get()` calls will resolve request-scoped services correctly,
|
|
53
|
+
* simulating a real HTTP request context.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* const module = await TestingModule.create(AppModule)
|
|
58
|
+
* .overrideProvider(DatabaseService)
|
|
59
|
+
* .useValue(mockDatabase)
|
|
60
|
+
* .init()
|
|
61
|
+
*
|
|
62
|
+
* const userService = await module.get(UserService)
|
|
63
|
+
* // ... run tests ...
|
|
64
|
+
*
|
|
65
|
+
* await module.close()
|
|
66
|
+
* ```
|
|
44
67
|
*/
|
|
45
68
|
declare class TestingModule {
|
|
46
69
|
private readonly appModule;
|
|
47
70
|
private readonly container;
|
|
48
71
|
private readonly options;
|
|
49
72
|
private app;
|
|
50
|
-
|
|
73
|
+
private scopedContainer;
|
|
74
|
+
private requestId;
|
|
75
|
+
private constructor();
|
|
76
|
+
/**
|
|
77
|
+
* Creates a new TestingModule for the given app module.
|
|
78
|
+
* This is the main entry point for setting up integration tests.
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```typescript
|
|
82
|
+
* const module = await TestingModule.create(AppModule)
|
|
83
|
+
* .overrideProvider(DatabaseService)
|
|
84
|
+
* .useValue(mockDatabase)
|
|
85
|
+
* .init()
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
static create(appModule: ClassTypeWithInstance<NaviosModule>, options?: TestingModuleOptions): TestingModule;
|
|
89
|
+
/**
|
|
90
|
+
* Compiles the testing module without initializing it.
|
|
91
|
+
* Call this if you need to access the app before initialization.
|
|
92
|
+
*
|
|
93
|
+
* @returns this for chaining
|
|
94
|
+
*/
|
|
95
|
+
compile(): Promise<this>;
|
|
51
96
|
/**
|
|
52
|
-
*
|
|
53
|
-
*
|
|
97
|
+
* Initializes the application and starts a request scope.
|
|
98
|
+
*
|
|
99
|
+
* This is equivalent to calling `compile()` followed by `app.init()`,
|
|
100
|
+
* plus starting a request context for proper request-scoped service resolution.
|
|
101
|
+
*
|
|
102
|
+
* @returns this for chaining
|
|
54
103
|
*/
|
|
55
|
-
|
|
104
|
+
init(): Promise<this>;
|
|
56
105
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
106
|
+
* Gets the compiled application.
|
|
107
|
+
*
|
|
108
|
+
* @throws Error if the module has not been compiled yet
|
|
59
109
|
*/
|
|
60
|
-
|
|
110
|
+
getApp(): NaviosApplication;
|
|
61
111
|
/**
|
|
62
112
|
* Gets the underlying TestContainer for direct manipulation.
|
|
63
113
|
*/
|
|
64
114
|
getContainer(): TestContainer;
|
|
65
115
|
/**
|
|
66
|
-
* Gets the
|
|
116
|
+
* Gets the scoped container for the current test request.
|
|
117
|
+
* Only available after calling `init()`.
|
|
118
|
+
*
|
|
119
|
+
* @throws Error if init() has not been called
|
|
67
120
|
*/
|
|
68
|
-
|
|
121
|
+
getScopedContainer(): ScopedContainer;
|
|
69
122
|
/**
|
|
70
|
-
* Override a provider with a mock value.
|
|
123
|
+
* Override a provider with a mock value or class.
|
|
124
|
+
* Must be called before `compile()` or `init()`.
|
|
71
125
|
*/
|
|
72
126
|
overrideProvider<T>(token: ClassType | InjectionToken<T, any>): {
|
|
73
127
|
useValue: (value: T) => TestingModule;
|
|
@@ -75,82 +129,264 @@ declare class TestingModule {
|
|
|
75
129
|
};
|
|
76
130
|
/**
|
|
77
131
|
* Gets an instance from the container.
|
|
132
|
+
*
|
|
133
|
+
* If `init()` has been called, this uses the scoped container
|
|
134
|
+
* which properly resolves request-scoped services.
|
|
135
|
+
*
|
|
136
|
+
* If only `compile()` was called, this uses the root container
|
|
137
|
+
* and request-scoped services will throw.
|
|
78
138
|
*/
|
|
79
139
|
get<T>(token: ClassTypeWithInstance<T> | InjectionToken<T, any>): Promise<T>;
|
|
80
140
|
/**
|
|
81
|
-
* Disposes the testing module and cleans up resources.
|
|
141
|
+
* Disposes the testing module and cleans up all resources.
|
|
142
|
+
*
|
|
143
|
+
* This will:
|
|
144
|
+
* 1. End the request scope (if started)
|
|
145
|
+
* 2. Close the application (if initialized)
|
|
146
|
+
* 3. Dispose the container
|
|
82
147
|
*/
|
|
83
148
|
close(): Promise<void>;
|
|
149
|
+
/**
|
|
150
|
+
* Asserts that a service has been resolved at least once.
|
|
151
|
+
*/
|
|
152
|
+
expectResolved(token: ClassType | InjectionToken<any, any>): void;
|
|
153
|
+
/**
|
|
154
|
+
* Asserts that a service has NOT been resolved.
|
|
155
|
+
*/
|
|
156
|
+
expectNotResolved(token: ClassType | InjectionToken<any, any>): void;
|
|
157
|
+
/**
|
|
158
|
+
* Asserts that a service is registered as singleton scope.
|
|
159
|
+
*/
|
|
160
|
+
expectSingleton(token: ClassType | InjectionToken<any, any>): void;
|
|
161
|
+
/**
|
|
162
|
+
* Asserts that a service is registered as transient scope.
|
|
163
|
+
*/
|
|
164
|
+
expectTransient(token: ClassType | InjectionToken<any, any>): void;
|
|
165
|
+
/**
|
|
166
|
+
* Asserts that a service is registered as request scope.
|
|
167
|
+
*/
|
|
168
|
+
expectRequestScoped(token: ClassType | InjectionToken<any, any>): void;
|
|
169
|
+
/**
|
|
170
|
+
* Asserts that a method was called on a service.
|
|
171
|
+
* Note: You must use `recordMethodCall()` in your mocks for this to work.
|
|
172
|
+
*/
|
|
173
|
+
expectCalled(token: ClassType | InjectionToken<any, any>, method: string): void;
|
|
174
|
+
/**
|
|
175
|
+
* Asserts that a method was called with specific arguments.
|
|
176
|
+
* Note: You must use `recordMethodCall()` in your mocks for this to work.
|
|
177
|
+
*/
|
|
178
|
+
expectCalledWith(token: ClassType | InjectionToken<any, any>, method: string, expectedArgs: unknown[]): void;
|
|
179
|
+
/**
|
|
180
|
+
* Asserts that a method was called a specific number of times.
|
|
181
|
+
* Note: You must use `recordMethodCall()` in your mocks for this to work.
|
|
182
|
+
*/
|
|
183
|
+
expectCallCount(token: ClassType | InjectionToken<any, any>, method: string, count: number): void;
|
|
184
|
+
/**
|
|
185
|
+
* Records a method call for tracking.
|
|
186
|
+
* Call this from your mock implementations to enable call assertions.
|
|
187
|
+
*/
|
|
188
|
+
recordMethodCall(token: ClassType | InjectionToken<any, any>, method: string, args: unknown[], result?: unknown, error?: Error): void;
|
|
189
|
+
/**
|
|
190
|
+
* Gets all recorded method calls for a service.
|
|
191
|
+
*/
|
|
192
|
+
getMethodCalls(token: ClassType | InjectionToken<any, any>): _navios_di_testing0.MethodCallRecord[];
|
|
193
|
+
/**
|
|
194
|
+
* Gets the dependency graph for debugging or snapshot testing.
|
|
195
|
+
*/
|
|
196
|
+
getDependencyGraph(): _navios_di_testing0.DependencyGraph;
|
|
197
|
+
/**
|
|
198
|
+
* Gets a simplified dependency graph showing only token relationships.
|
|
199
|
+
*/
|
|
200
|
+
getSimplifiedDependencyGraph(): Record<string, string[]>;
|
|
84
201
|
}
|
|
85
202
|
/**
|
|
86
|
-
*
|
|
203
|
+
* Creates a testing module for the given app module.
|
|
204
|
+
*
|
|
205
|
+
* @deprecated Use `TestingModule.create()` instead.
|
|
87
206
|
*
|
|
88
|
-
*
|
|
207
|
+
* @example
|
|
208
|
+
* ```typescript
|
|
209
|
+
* // Old way (deprecated)
|
|
210
|
+
* const module = createTestingModule(AppModule)
|
|
211
|
+
*
|
|
212
|
+
* // New way
|
|
213
|
+
* const module = TestingModule.create(AppModule)
|
|
214
|
+
* ```
|
|
89
215
|
*/
|
|
90
|
-
|
|
216
|
+
declare function createTestingModule(appModule: ClassTypeWithInstance<NaviosModule>, options?: TestingModuleOptions): TestingModule;
|
|
217
|
+
//#endregion
|
|
218
|
+
//#region src/testing/unit-testing-module.d.mts
|
|
219
|
+
/**
|
|
220
|
+
* Options for creating a UnitTestingModule.
|
|
221
|
+
*/
|
|
222
|
+
interface UnitTestingModuleOptions {
|
|
91
223
|
/**
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
* @param token - The injection token or class to override
|
|
95
|
-
* @returns An object with `useValue` and `useClass` methods for chaining
|
|
96
|
-
*
|
|
97
|
-
* @example
|
|
98
|
-
* ```typescript
|
|
99
|
-
* const testingModule = await createTestingModule(AppModule)
|
|
100
|
-
* .overrideProvider(DatabaseService)
|
|
101
|
-
* .useValue(mockDatabaseService)
|
|
102
|
-
* .compile()
|
|
103
|
-
* ```
|
|
224
|
+
* List of providers to register. Only these services can be resolved.
|
|
104
225
|
*/
|
|
105
|
-
|
|
106
|
-
useValue: (value: T) => TestingModuleBuilder;
|
|
107
|
-
useClass: (target: ClassType) => TestingModuleBuilder;
|
|
108
|
-
};
|
|
226
|
+
providers: ProviderConfig[];
|
|
109
227
|
/**
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
* This creates the application instance but does not initialize it.
|
|
113
|
-
* Call `init()` if you need the application to be fully initialized.
|
|
228
|
+
* If true, unregistered dependencies will be auto-mocked instead of throwing.
|
|
229
|
+
* Default: false (throws on unregistered dependencies)
|
|
114
230
|
*/
|
|
115
|
-
|
|
231
|
+
allowUnregistered?: boolean;
|
|
116
232
|
/**
|
|
117
|
-
*
|
|
233
|
+
* Logger for debugging.
|
|
234
|
+
*/
|
|
235
|
+
logger?: Console | null;
|
|
236
|
+
/**
|
|
237
|
+
* Container to use for the testing module.
|
|
238
|
+
* If not provided, a new UnitTestContainer will be created.
|
|
239
|
+
*/
|
|
240
|
+
container?: UnitTestContainer;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* A lightweight testing module for isolated unit tests.
|
|
244
|
+
*
|
|
245
|
+
* Unlike `TestingModule`, this does NOT load Navios modules or create an application.
|
|
246
|
+
* It uses `UnitTestContainer` which:
|
|
247
|
+
* - Only allows explicitly provided services
|
|
248
|
+
* - Automatically tracks all method calls via proxies
|
|
249
|
+
* - Can auto-mock unregistered dependencies
|
|
250
|
+
*
|
|
251
|
+
* This is ideal for testing services in isolation without the overhead
|
|
252
|
+
* of full module loading.
|
|
253
|
+
*
|
|
254
|
+
* @example
|
|
255
|
+
* ```typescript
|
|
256
|
+
* const module = UnitTestingModule.create({
|
|
257
|
+
* providers: [
|
|
258
|
+
* { token: UserService, useClass: UserService },
|
|
259
|
+
* { token: DatabaseService, useValue: mockDatabase },
|
|
260
|
+
* ],
|
|
261
|
+
* })
|
|
262
|
+
*
|
|
263
|
+
* const userService = await module.get(UserService)
|
|
264
|
+
* await userService.findUser('123')
|
|
265
|
+
*
|
|
266
|
+
* // Method calls are automatically tracked
|
|
267
|
+
* module.expectCalled(UserService, 'findUser')
|
|
268
|
+
* module.expectCalledWith(UserService, 'findUser', ['123'])
|
|
269
|
+
*
|
|
270
|
+
* await module.close()
|
|
271
|
+
* ```
|
|
272
|
+
*/
|
|
273
|
+
declare class UnitTestingModule {
|
|
274
|
+
private readonly container;
|
|
275
|
+
private constructor();
|
|
276
|
+
/**
|
|
277
|
+
* Creates a new UnitTestingModule with the given providers.
|
|
118
278
|
*
|
|
119
|
-
*
|
|
279
|
+
* @example
|
|
280
|
+
* ```typescript
|
|
281
|
+
* const module = UnitTestingModule.create({
|
|
282
|
+
* providers: [
|
|
283
|
+
* { token: UserService, useClass: UserService },
|
|
284
|
+
* { token: ConfigToken, useValue: { apiUrl: 'test' } },
|
|
285
|
+
* ],
|
|
286
|
+
* })
|
|
287
|
+
* ```
|
|
120
288
|
*/
|
|
121
|
-
|
|
289
|
+
static create(options: UnitTestingModuleOptions): UnitTestingModule;
|
|
122
290
|
/**
|
|
123
|
-
* Gets the underlying
|
|
291
|
+
* Gets the underlying UnitTestContainer for direct manipulation.
|
|
124
292
|
*/
|
|
125
|
-
getContainer():
|
|
293
|
+
getContainer(): UnitTestContainer;
|
|
126
294
|
/**
|
|
127
295
|
* Gets an instance from the container.
|
|
128
296
|
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
297
|
+
* All resolved instances are wrapped in tracking proxies,
|
|
298
|
+
* so method calls are automatically recorded.
|
|
299
|
+
*
|
|
300
|
+
* @throws Error if the token is not in the providers list
|
|
301
|
+
* and `allowUnregistered` is false
|
|
132
302
|
*/
|
|
133
303
|
get<T>(token: ClassTypeWithInstance<T> | InjectionToken<T, any>): Promise<T>;
|
|
134
304
|
/**
|
|
135
|
-
* Disposes the
|
|
305
|
+
* Disposes the module and cleans up all resources.
|
|
136
306
|
*/
|
|
137
307
|
close(): Promise<void>;
|
|
308
|
+
/**
|
|
309
|
+
* Enables auto-mocking for unregistered dependencies.
|
|
310
|
+
* Unregistered services will return a proxy that throws on method access.
|
|
311
|
+
*/
|
|
312
|
+
enableAutoMocking(): this;
|
|
313
|
+
/**
|
|
314
|
+
* Disables auto-mocking (strict mode).
|
|
315
|
+
* Unregistered dependencies will throw immediately on resolution.
|
|
316
|
+
*/
|
|
317
|
+
disableAutoMocking(): this;
|
|
318
|
+
/**
|
|
319
|
+
* Asserts that a service has been resolved at least once.
|
|
320
|
+
*/
|
|
321
|
+
expectResolved(token: ClassType | InjectionToken<any, any>): void;
|
|
322
|
+
/**
|
|
323
|
+
* Asserts that a service has NOT been resolved.
|
|
324
|
+
*/
|
|
325
|
+
expectNotResolved(token: ClassType | InjectionToken<any, any>): void;
|
|
326
|
+
/**
|
|
327
|
+
* Asserts that a service was auto-mocked (not in providers list).
|
|
328
|
+
*/
|
|
329
|
+
expectAutoMocked(token: ClassType | InjectionToken<any, any>): void;
|
|
330
|
+
/**
|
|
331
|
+
* Asserts that a service was NOT auto-mocked (is in providers list).
|
|
332
|
+
*/
|
|
333
|
+
expectNotAutoMocked(token: ClassType | InjectionToken<any, any>): void;
|
|
334
|
+
/**
|
|
335
|
+
* Asserts that a method was called on a service.
|
|
336
|
+
* Method calls are automatically tracked via proxy.
|
|
337
|
+
*/
|
|
338
|
+
expectCalled(token: ClassType | InjectionToken<any, any>, method: string): void;
|
|
339
|
+
/**
|
|
340
|
+
* Asserts that a method was NOT called on a service.
|
|
341
|
+
*/
|
|
342
|
+
expectNotCalled(token: ClassType | InjectionToken<any, any>, method: string): void;
|
|
343
|
+
/**
|
|
344
|
+
* Asserts that a method was called with specific arguments.
|
|
345
|
+
*/
|
|
346
|
+
expectCalledWith(token: ClassType | InjectionToken<any, any>, method: string, expectedArgs: unknown[]): void;
|
|
347
|
+
/**
|
|
348
|
+
* Asserts that a method was called a specific number of times.
|
|
349
|
+
*/
|
|
350
|
+
expectCallCount(token: ClassType | InjectionToken<any, any>, method: string, count: number): void;
|
|
351
|
+
/**
|
|
352
|
+
* Gets all recorded method calls for a service.
|
|
353
|
+
*/
|
|
354
|
+
getMethodCalls(token: ClassType | InjectionToken<any, any>): MethodCallRecord[];
|
|
355
|
+
/**
|
|
356
|
+
* Gets statistics about a service (instance count, method calls, lifecycle events).
|
|
357
|
+
*/
|
|
358
|
+
getServiceStats(token: ClassType | InjectionToken<any, any>): MockServiceStats;
|
|
359
|
+
/**
|
|
360
|
+
* Clears all recorded method calls.
|
|
361
|
+
* Useful for resetting state between test assertions.
|
|
362
|
+
*/
|
|
363
|
+
clearMethodCalls(): void;
|
|
364
|
+
/**
|
|
365
|
+
* Gets list of all registered provider token IDs.
|
|
366
|
+
*/
|
|
367
|
+
getRegisteredTokenIds(): ReadonlySet<string>;
|
|
368
|
+
/**
|
|
369
|
+
* Gets list of all auto-mocked token IDs.
|
|
370
|
+
*/
|
|
371
|
+
getAutoMockedTokenIds(): ReadonlySet<string>;
|
|
372
|
+
/**
|
|
373
|
+
* Asserts that a service's onServiceInit was called.
|
|
374
|
+
*/
|
|
375
|
+
expectInitialized(token: ClassType | InjectionToken<any, any>): void;
|
|
376
|
+
/**
|
|
377
|
+
* Asserts that a service's onServiceDestroy was called.
|
|
378
|
+
*/
|
|
379
|
+
expectDestroyed(token: ClassType | InjectionToken<any, any>): void;
|
|
380
|
+
/**
|
|
381
|
+
* Asserts that a service has NOT been destroyed.
|
|
382
|
+
*/
|
|
383
|
+
expectNotDestroyed(token: ClassType | InjectionToken<any, any>): void;
|
|
384
|
+
/**
|
|
385
|
+
* Records a lifecycle event for tracking.
|
|
386
|
+
* Call this from your mock implementations if needed.
|
|
387
|
+
*/
|
|
388
|
+
recordLifecycleEvent(token: ClassType | InjectionToken<any, any>, event: 'created' | 'initialized' | 'destroyed', instanceName: string): void;
|
|
138
389
|
}
|
|
139
|
-
/**
|
|
140
|
-
* Creates a testing module for the given app module.
|
|
141
|
-
* This is the main entry point for setting up tests.
|
|
142
|
-
*
|
|
143
|
-
* @example
|
|
144
|
-
* ```typescript
|
|
145
|
-
* const testingModule = await createTestingModule(AppModule, {
|
|
146
|
-
* adapter: [],
|
|
147
|
-
* })
|
|
148
|
-
* .overrideProvider(DatabaseService)
|
|
149
|
-
* .useValue(mockDatabaseService)
|
|
150
|
-
* .compile()
|
|
151
|
-
* ```
|
|
152
|
-
*/
|
|
153
|
-
declare function createTestingModule(appModule: ClassTypeWithInstance<NaviosModule>, options?: TestingModuleOptions): TestingModule;
|
|
154
390
|
//#endregion
|
|
155
|
-
export { TestingModule,
|
|
391
|
+
export { TestingModule, TestingModuleOptions, TestingModuleOverride, UnitTestingModule, UnitTestingModuleOptions, createTestingModule };
|
|
156
392
|
//# sourceMappingURL=index.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/testing/testing-module.mts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/testing/testing-module.mts","../../src/testing/unit-testing-module.mts"],"sourcesContent":[],"mappings":";;;;;;;;;;;AAoBA;;AAIoC,UAJnB,qBAImB,CAAA,IAAA,GAAA,CAAA,CAAA;EAAf;;;EAQC,KAAA,EARb,SAQa,GARD,cAQC,CARc,CAQd,EAAA,GAAA,CAAA;EASL;;;EAcH,QAAA,CAAA,EA3BD,CA2BC;EAdgC;;AAsC9C;EAwBqC,QAAA,CAAA,EAvExB,SAuEwB;;;;;;;;AAwFb,UAtJP,oBAAA,SAA6B,IAsJtB,CArJtB,wBAqJsB,EAAA,WAAA,CAAA,CAAA;EAWK;;;;;EAEN,SAAA,CAAA,EA1JT,qBA0JS,EAAA;EAAc;;;;EAwBC,SAAA,CAAA,EA7KxB,aA6KwB;;;;;;;;;;;;;;;;;;;;;;;AA8Hd,cAnRX,aAAA,CAmRW;EAAY,iBAAA,SAAA;EAAc,iBAAU,SAAA;EAAA,iBAOxC,OAAA;EAOU,QAAA,GAAA;EAAA,QAAA,eAAA;EAmBd,QAAA,SAAA;EACmB,QAAA,WAAA,CAAA;EAAtB;;;;;;;ACpXb;;;;;EAuDa,OAAA,MAAA,CAAA,SAAiB,EDgCf,qBChCe,CDgCO,YChCP,CAAA,EAAA,OAAA,CAAA,EDiCjB,oBCjCiB,CAAA,EDkCzB,aClCyB;EAgBL;;;;;;EA6Ba,OAAA,CAAA,CAAA,EDgBnB,OChBmB,CAAA,IAAA,CAAA;EACzB;;;;;;;;EAkDyB,IAAA,CAAA,CAAA,EDjBtB,OCiBsB,CAAA,I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