Skip to content
This repository was archived by the owner on Dec 17, 2025. It is now read-only.

Commit d2a7757

Browse files
committed
fix: tests working
1 parent 0fea0d6 commit d2a7757

File tree

7 files changed

+65
-38
lines changed

7 files changed

+65
-38
lines changed

jest.config.js

Lines changed: 0 additions & 20 deletions
This file was deleted.

jest.config.mjs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/** @type {import('ts-jest').JestConfigWithTsJest} */
2+
const config = {
3+
preset: 'ts-jest/presets/default-esm',
4+
testEnvironment: 'node',
5+
roots: ['<rootDir>/src', '<rootDir>/test'],
6+
testMatch: ['**/__tests__/**/*.ts', '**/?(*.)+(spec|test).ts'],
7+
collectCoverageFrom: [
8+
'src/**/*.ts',
9+
'!src/**/*.d.ts',
10+
'!src/**/__tests__/**'
11+
],
12+
coverageThreshold: {
13+
global: {
14+
branches: 90,
15+
functions: 90,
16+
lines: 90,
17+
statements: 90
18+
}
19+
},
20+
transform: {
21+
'^.+\\.tsx?$': [
22+
'ts-jest',
23+
{
24+
useESM: true,
25+
tsconfig: {
26+
module: 'ESNext',
27+
moduleResolution: 'NodeNext'
28+
}
29+
}
30+
]
31+
},
32+
extensionsToTreatAsEsm: ['.ts'],
33+
moduleNameMapper: {
34+
'^(\\.{1,2}/.*)\\.js$': '$1'
35+
}
36+
};
37+
38+
export default config;

src/commands/init.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ContextGenerator } from '../lib/ContextGenerator';
1+
import { ContextGenerator } from '../lib/ContextGenerator.js';
22

33
export const init = async () => {
44
try {

src/commands/lint.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
import { ContextLinter } from '../lib/ContextLinter';
1+
import { ContextLinter } from '../lib/ContextLinter.js';
2+
3+
interface LintIssue {
4+
message: string;
5+
file: string;
6+
line: number;
7+
suggestion?: string;
8+
}
29

310
interface LintOptions {
411
fix?: boolean;
@@ -14,7 +21,7 @@ export const lint = async (options: LintOptions) => {
1421
process.exit(0);
1522
} else {
1623
console.log('\nLinting issues found:');
17-
results.issues.forEach(issue => {
24+
results.issues.forEach((issue: LintIssue) => {
1825
console.log(`\n❌ ${issue.message}`);
1926
console.log(` File: ${issue.file}`);
2027
console.log(` Line: ${issue.line}`);

src/commands/validate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ContextValidator } from '../lib/ContextValidator';
1+
import { ContextValidator } from '../lib/ContextValidator.js';
22

33
export const validate = async () => {
44
try {

test/cli.test.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
import { exec } from 'child_process';
2-
import { promisify } from 'util';
3-
import path from 'path';
4-
import fs from 'fs/promises';
5-
import { fileURLToPath } from 'url';
6-
const __filename = fileURLToPath(import.meta.url);
7-
const __dirname = path.dirname(__filename);
1+
import { exec } from 'node:child_process';
2+
import { promisify } from 'node:util';
3+
import path from 'node:path';
4+
import fs from 'node:fs/promises';
85

96
const execAsync = promisify(exec);
107

118
console.log('Running tests...');
129

13-
const cliPath = path.resolve(__dirname, '../src/index.js');
10+
const cliPath = path.resolve(__dirname, '../dist/index.js');
1411
const testDir = path.resolve(__dirname, 'test-context');
1512

1613
describe('CLI', () => {

tsconfig.json

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"compilerOptions": {
3-
"target": "ES2020",
4-
"module": "ES2020",
5-
"moduleResolution": "node",
3+
"target": "ES2022",
4+
"module": "NodeNext",
5+
"moduleResolution": "NodeNext",
66
"esModuleInterop": true,
77
"strict": true,
88
"skipLibCheck": true,
@@ -13,8 +13,13 @@
1313
"baseUrl": ".",
1414
"paths": {
1515
"@modelcontextprotocol/sdk/*": ["node_modules/@modelcontextprotocol/sdk/dist/*"]
16-
}
16+
},
17+
"types": ["node", "jest"]
1718
},
18-
"include": ["src/**/*"],
19-
"exclude": ["node_modules", "dist", "test"]
19+
"ts-node": {
20+
"esm": true,
21+
"experimentalSpecifierResolution": "node"
22+
},
23+
"include": ["src/**/*", "test/**/*"],
24+
"exclude": ["node_modules", "dist"]
2025
}

0 commit comments

Comments
 (0)