|
11 | 11 | */ |
12 | 12 |
|
13 | 13 | import { describe, it, expect, beforeEach } from 'vitest'; |
14 | | -import { ObjectKernel } from './kernel'; |
15 | | -import { PluginLoader, ServiceLifecycle } from './plugin-loader'; |
16 | | -import { createLogger } from './logger'; |
17 | | -import type { PluginContext } from './types'; |
| 14 | +import { ObjectKernel } from './kernel.js'; |
| 15 | +import { PluginLoader, ServiceLifecycle } from './plugin-loader.js'; |
| 16 | +import { createLogger } from './logger.js'; |
| 17 | +import type { PluginContext } from './types.js'; |
18 | 18 | import { |
19 | 19 | isServiceNotRegisteredError, |
20 | 20 | SERVICE_NOT_REGISTERED_CODE, |
21 | | -} from './service-not-registered'; |
| 21 | +} from './service-not-registered.js'; |
22 | 22 |
|
23 | 23 | function makeLoader(withContext = true): PluginLoader { |
24 | 24 | const logger = createLogger({ level: 'error' }); |
25 | 25 | const loader = new PluginLoader(logger); |
26 | 26 | if (withContext) { |
27 | | - loader.setContext({ |
| 27 | + // A real `PluginContext`, not a cast: the loader only ever hands this to |
| 28 | + // a factory, and every member is spelled so the compiler checks the |
| 29 | + // shape instead of a `as unknown as` silencing it. |
| 30 | + const ctx: PluginContext = { |
28 | 31 | registerService: () => {}, |
| 32 | + registerServiceFactory: () => {}, |
29 | 33 | getService: () => { throw new Error('Mock service not found'); }, |
| 34 | + replaceService: () => {}, |
| 35 | + getServiceScoped: async () => { throw new Error('not used'); }, |
| 36 | + getServices: () => new Map<string, any>(), |
30 | 37 | hook: () => {}, |
31 | 38 | trigger: async () => {}, |
32 | | - getServices: () => new Map(), |
33 | 39 | logger, |
34 | 40 | getKernel: () => ({}) as any, |
35 | | - } as PluginContext); |
| 41 | + }; |
| 42 | + loader.setContext(ctx); |
36 | 43 | } |
37 | 44 | return loader; |
38 | 45 | } |
@@ -218,7 +225,7 @@ describe('[#13905] the SUPPORTED no-data-plane kernel stays quiet, the broken on |
218 | 225 |
|
219 | 226 | describe('[#13905] the published increment', () => { |
220 | 227 | it('reaches consumers through the package entry point, and is exactly two symbols', async () => { |
221 | | - const core: Record<string, unknown> = await import('./index'); |
| 228 | + const core: Record<string, unknown> = await import('./index.js'); |
222 | 229 |
|
223 | 230 | expect(typeof core.isServiceNotRegisteredError).toBe('function'); |
224 | 231 | expect(core.SERVICE_NOT_REGISTERED_CODE).toBe('SERVICE_NOT_REGISTERED'); |
|
0 commit comments