test-execution-plan.json•4.92 kB
{
  "schema": "memory_document_v1",
  "metadata": {
    "title": "test-execution-plan.json",
    "documentType": "generic",
    "path": "test-execution-plan.json",
    "tags": [],
    "lastModified": "2025-03-28T06:36:18.155Z"
  },
  "content": {
    "text": "{\n  \"schema\": \"memory_document_v2\",\n  \"metadata\": {\n    \"id\": \"test-execution-plan\",\n    \"title\": \"テスト実行エラー修正計画\",\n    \"documentType\": \"plan\",\n    \"path\": \"test-execution-plan.json\",\n    \"tags\": [\n      \"test\",\n      \"jest\",\n      \"error\",\n      \"plan\"\n    ],\n    \"lastModified\": \"2025-03-28T17:50:00.000Z\",\n    \"createdAt\": \"2025-03-28T17:50:00.000Z\",\n    \"version\": 1\n  },\n  \"content\": {\n    \"overview\": {\n      \"description\": \"packages/mcp でテストを実行した際に発生したBabelパーサーエラーの修正計画\",\n      \"error\": \"unexpected token with Babel parser at @babel/parser\",\n      \"cause\": \"パッケージレベルでのJestの設定ファイルが不足している可能性があり、現在はルートのJest設定に依存している\",\n      \"solution\": \"packages/mcp ディレクトリにJestの適切な設定ファイルを作成し、ESM形式でのテスト実行をサポートする\"\n    },\n    \"priorities\": [\n      {\n        \"id\": \"jest-config\",\n        \"description\": \"packages/mcp/jest.config.js(またはts)ファイルを作成\",\n        \"priority\": \"high\"\n      },\n      {\n        \"id\": \"babel-config\",\n        \"description\": \"必要に応じて babel.config.js を設定\",\n        \"priority\": \"medium\"\n      },\n      {\n        \"id\": \"test-execution\",\n        \"description\": \"設定完了後にテストを再実行\",\n        \"priority\": \"high\"\n      }\n    ],\n    \"implementation\": {\n      \"jestConfig\": {\n        \"filename\": \"packages/mcp/jest.config.js\",\n        \"format\": \"ESM\",\n        \"key_settings\": [\n          \"preset: 'ts-jest/presets/default-esm'\",\n          \"testEnvironment: 'node'\",\n          \"extensionsToTreatAsEsm: ['.ts']\",\n          \"moduleNameMapper: { ... }\"\n        ]\n      },\n      \"moduleMapper\": {\n        \"description\": \"ESM形式でインポートパスを解決するための重要な設定\",\n        \"pattern\": {\n          \"'^(\\\\.{1,2}/.*)\\\\.js$': '$1'\n        },\n        \"explanation\": \"TypeScriptのESM形式では、.jsを含むインポートパスが生成されるが、実際のファイルは.tsのままなので変換が必要\"\n      }\n    },\n    \"jestConfigContent\": {\n      \"es_module\": \"/** @type {import('jest').Config} */\\nexport default {\\n  preset: 'ts-jest/presets/default-esm',\\n  testEnvironment: 'node',\\n  rootDir: '.',\\n  testMatch: ['<rootDir>/tests/**/*.test.ts'],\\n  transform: {\\n    '^.+\\\\\\\\.tsx?$': ['ts-jest', {\\n      useESM: true,\\n      tsconfig: 'tsconfig.json'\\n    }]\\n  },\\n  moduleNameMapper: {\\n    '^(\\\\\\\\.{1,2}/.*)\\\\\\\\.js$': '$1', // ESM import support\\n    '^@memory-bank/schemas(.*)$': '<rootDir>/../schemas/src$1'\\n  },\\n  extensionsToTreatAsEsm: ['.ts'],\\n  verbose: true,\\n  testTimeout: 10000,\\n  maxWorkers: 1\\n};\"\n    },\n    \"testingSteps\": [\n      {\n        \"step\": \"jest.config.js ファイルを作成\",\n        \"details\": \"plans.jestConfigContent.es_module の内容で configs.jestConfig.filename を作成する\"\n      },\n      {\n        \"step\": \"テスト実行\",\n        \"details\": \"packages/mcp ディレクトリで npm test を実行し、動作を確認\",\n        \"command\": \"cd /Users/t3ta/workspace/memory-bank-mcp-server/packages/mcp && npm run test\"\n      },\n      {\n        \"step\": \"エラー確認とトラブルシューティング\",\n        \"details\": \"エラーが続く場合、ModuleNameMapperを調整するか、さらに babel.config.js の追加を検討する\"\n      }\n    ],\n    \"alternativeSolutions\": [\n      {\n        \"id\": \"reduce-complexity\",\n        \"description\": \"テストファイルを簡素化して、最低限の機能だけでテストするバージョンを作成する\",\n        \"when_to_use\": \"設定だけでは解決できない場合\"\n      },\n      {\n        \"id\": \"use-common-jest-config\",\n        \"description\": \"Root設定と同じJest設定を使用するが、moduleNameMapperだけを調整する\",\n        \"when_to_use\": \"パッケージごとの設定が複雑になりすぎる場合\"\n      }\n    ],\n    \"references\": {\n      \"ts_jest_esm\": \"https://kulshekhar.github.io/ts-jest/docs/guides/esm-support/\",\n      \"babel_parser_error\": \"https://github.com/babel/babel/issues/13690\",\n      \"jest_workspaces\": \"https://jestjs.io/docs/configuration#projects-arraystring--projectconfig\"\n    }\n  }\n}"
  }
}