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,12 @@ 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 and @langchain /core are ESM-only packages.
15+ // They cannot be require()'d in Jest's CJS environment and crash 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+ '^@modelcontextprotocol/sdk/(.*)$' : '<rootDir>/test/__mocks__/esm-stub.js' ,
19+ '^@langchain/core/(.*)$' : '<rootDir>/test/__mocks__/esm-stub.js'
1420 }
1521}
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