File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,6 +10,13 @@ module.exports = {
1010 verbose : true ,
1111 testPathIgnorePatterns : [ '/node_modules/' , '/dist/' ] ,
1212 moduleNameMapper : {
13- '^../../../src/(.*)$' : '<rootDir>/src/$1'
13+ '^../../../src/(.*)$' : '<rootDir>/src/$1' ,
14+ // @modelcontextprotocol /sdk is ESM-only (type:module, no exports map, no CJS builds).
15+ // It cannot be require()'d in Jest's CJS environment and crashes the worker.
16+ // The MCP core tests only exercise pure validation functions that don't
17+ // use these imports, so stubbing them out is safe.
18+ // Note: @langchain /core is NOT stubbed here because it ships CJS builds
19+ // (e.g. tools.cjs) that Jest can require() normally.
20+ '^@modelcontextprotocol/sdk/(.*)$' : '<rootDir>/test/__mocks__/esm-stub.js'
1421 }
1522}
Original file line number Diff line number Diff line change 1+ /**
2+ * Stub for ESM-only packages that cannot be require()'d in Jest's CJS environment.
3+ *
4+ * Returns a real ES6 class for every named export so that patterns like
5+ * class MCPToolkit extends BaseToolkit { ... }
6+ * don't crash at module-load time, even though the class is never instantiated
7+ * in these tests.
8+ */
9+ class Stub { }
10+
11+ module . exports = new Proxy (
12+ { } ,
13+ {
14+ get : ( _target , prop ) => {
15+ if ( prop === '__esModule' ) return false
16+ return Stub
17+ }
18+ }
19+ )
You can’t perform that action at this time.
0 commit comments