Skip to content

Commit 1bfb836

Browse files
author
christopherholland-workday
committed
Fix test coverage failures
1 parent bc958c9 commit 1bfb836

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

packages/components/jest.config.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff 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
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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+
)

0 commit comments

Comments
 (0)