Skip to content

Commit 3ba827d

Browse files
christopherholland-workdaychristopherholland-workday
andauthored
Fix test coverage failures (#5839)
* Fix test coverage failures * Fix test coverage failures * Fix test coverage failures * Fix test coverage failures --------- Co-authored-by: christopherholland-workday <christopher.holland+evisort@workday.com>
1 parent 1a6f914 commit 3ba827d

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

packages/components/jest.config.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff 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
}
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)