dhis2_generate_test_setup
Set up DHIS2 app testing environments by configuring frameworks like Jest, Cypress, or Playwright and generating unit, integration, e2e, or visual tests with mock setups for APIs, DataStore, and authentication.
Instructions
Generate testing setup and example tests for DHIS2 app
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| coverage | No | ||
| mockSetup | No | ||
| testFramework | Yes | Testing framework to configure | |
| testTypes | No | Types of tests to set up |
Implementation Reference
- src/index.ts:1127-1137 (handler)MCP tool handler that extracts arguments, calls generateTestSetup function, and returns markdown-formatted testing setup instructions.case 'dhis2_generate_test_setup': const testArgs = args as any; const testSetup = generateTestSetup(testArgs); return { content: [ { type: 'text', text: testSetup, }, ], };
- src/webapp-generators.ts:1193-1223 (helper)Helper function that generates complete testing setup documentation including framework configs, test examples, mocks, and commands for Jest, Cypress, Playwright, etc.export function generateTestSetup(args: any): string { const { testFramework, testTypes = [], coverage = {}, mockSetup = {} } = args; return `# DHIS2 Testing Setup ## ${testFramework.toUpperCase()} Configuration ${generateTestFrameworkConfig(testFramework, coverage)} ${testTypes.includes('unit') ? generateUnitTestExamples() : ''} ${testTypes.includes('integration') ? generateIntegrationTestExamples() : ''} ${testTypes.includes('e2e') ? generateE2ETestExamples(testFramework) : ''} ${testTypes.includes('visual') ? generateVisualTestExamples() : ''} ${Object.keys(mockSetup).length > 0 ? generateMockConfiguration(mockSetup) : ''} ## Test Commands \`\`\`bash # Run all tests ${testFramework === 'jest' ? 'npm test' : testFramework === 'cypress' ? 'npx cypress open' : 'npx playwright test'} # Run with coverage ${testFramework === 'jest' ? 'npm test -- --coverage' : 'npm run test:coverage'} # Run specific test file ${testFramework === 'jest' ? 'npm test -- MyComponent.test.js' : testFramework === 'cypress' ? 'npx cypress run --spec "cypress/integration/MyComponent.spec.js"' : 'npx playwright test tests/MyComponent.spec.ts'} # Watch mode ${testFramework === 'jest' ? 'npm test -- --watch' : 'npm run test:watch'} \`\`\` `;
- src/permission-system.ts:142-142 (registration)Tool permission registration mapping 'dhis2_generate_test_setup' to 'canConfigureApps' permission.['dhis2_generate_test_setup', 'canConfigureApps'],