diff --git a/src/__mocks__/execa.js b/src/__mocks__/execa.js new file mode 100644 index 0000000000..5d6b1b219c --- /dev/null +++ b/src/__mocks__/execa.js @@ -0,0 +1,13 @@ +// Mock implementation of execa +module.exports = { + execa: jest.fn().mockResolvedValue({ + stdout: "", + stderr: "", + exitCode: 0, + }), + execaSync: jest.fn().mockReturnValue({ + stdout: "", + stderr: "", + exitCode: 0, + }), +} diff --git a/src/jest.config.mjs b/src/jest.config.mjs index 64800beeeb..f98dd8821f 100644 --- a/src/jest.config.mjs +++ b/src/jest.config.mjs @@ -38,9 +38,10 @@ export default { "^os-name$": "/__mocks__/os-name.js", "^strip-bom$": "/__mocks__/strip-bom.js", "^kontroll$": "/__mocks__/kontroll.js", + "^execa$": "/__mocks__/execa.js", }, transformIgnorePatterns: [ - "node_modules/(?!(@modelcontextprotocol|delay|p-wait-for|serialize-error|strip-ansi|default-shell|os-name|strip-bom|kontroll)/)", + "node_modules/(?!(@modelcontextprotocol|delay|p-wait-for|serialize-error|strip-ansi|default-shell|os-name|strip-bom|kontroll|execa)/)", ], roots: [""], modulePathIgnorePatterns: ["dist", "out"], diff --git a/src/services/marketplace/__tests__/MetadataScanner.test.ts b/src/services/marketplace/__tests__/MetadataScanner.test.ts index 85f4bece93..e866d544f1 100644 --- a/src/services/marketplace/__tests__/MetadataScanner.test.ts +++ b/src/services/marketplace/__tests__/MetadataScanner.test.ts @@ -73,6 +73,8 @@ describe("MetadataScanner", () => { const normalizedBasePath = normalizePath(mockBasePath) const normalizedComponentPath = normalizePath(path.join(mockBasePath, "component1")) + process.stdout.write(`\nMock readdir called with path: ${normalizedP}\n`) + if (normalizedP === normalizedBasePath) { // For the base path, return only the component directory const baseDirents = [componentDirDirent] @@ -87,15 +89,16 @@ describe("MetadataScanner", () => { } }) - mockedFs.readFile.mockResolvedValue( - Buffer.from(` + mockedFs.readFile.mockImplementation(async (p: string | Buffer | URL | FileHandle) => { + process.stdout.write(`\nMock readFile called with path: ${String(p)}\n`) + return Buffer.from(` name: Test Component description: A test component type: mcp version: 1.0.0 sourceUrl: https://example.com/component1 -`), - ) +`) + }) const items = await metadataScanner.scanDirectory(mockBasePath, mockRepoUrl)