Skip to content

Commit 6c52386

Browse files
committed
test(core): spell the contract test's imports and mock context so tsc checks them
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F3jdziLbAPGeceVNmSox5L
1 parent 5f22530 commit 6c52386

1 file changed

Lines changed: 16 additions & 9 deletions

File tree

packages/core/src/service-resolution-discriminator.contract.test.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,35 @@
1111
*/
1212

1313
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';
1818
import {
1919
isServiceNotRegisteredError,
2020
SERVICE_NOT_REGISTERED_CODE,
21-
} from './service-not-registered';
21+
} from './service-not-registered.js';
2222

2323
function makeLoader(withContext = true): PluginLoader {
2424
const logger = createLogger({ level: 'error' });
2525
const loader = new PluginLoader(logger);
2626
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 = {
2831
registerService: () => {},
32+
registerServiceFactory: () => {},
2933
getService: () => { throw new Error('Mock service not found'); },
34+
replaceService: () => {},
35+
getServiceScoped: async () => { throw new Error('not used'); },
36+
getServices: () => new Map<string, any>(),
3037
hook: () => {},
3138
trigger: async () => {},
32-
getServices: () => new Map(),
3339
logger,
3440
getKernel: () => ({}) as any,
35-
} as PluginContext);
41+
};
42+
loader.setContext(ctx);
3643
}
3744
return loader;
3845
}
@@ -218,7 +225,7 @@ describe('[#13905] the SUPPORTED no-data-plane kernel stays quiet, the broken on
218225

219226
describe('[#13905] the published increment', () => {
220227
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');
222229

223230
expect(typeof core.isServiceNotRegisteredError).toBe('function');
224231
expect(core.SERVICE_NOT_REGISTERED_CODE).toBe('SERVICE_NOT_REGISTERED');

0 commit comments

Comments
 (0)