Skip to content

Commit bb2c509

Browse files
facundofariasclaude
andcommitted
test: Add comprehensive test suite with Vitest
Add unit tests for core MCP server functionality: Test Coverage: - Tool schema validation (25 tests) - All 6 MCP tools with valid/invalid inputs - Tool array structure and metadata - API client methods (22 tests) - All CRUD operations with mocked fetch - Error handling (401, 403, 422, 500, network) - Request formatting and headers - MCP server factory (4 tests) - Server instantiation and configuration Infrastructure: - Add Vitest testing framework (@vitest/ui for debugging) - Add vitest.config.ts with coverage configuration - Update package.json with test scripts: - npm test: Run tests once - npm run test:watch: Watch mode - npm run test:coverage: Coverage report - npm run test:ui: Interactive UI - Add test step to CI workflow (all Node versions) - Update README with testing documentation Results: 51 tests passing across 3 test suites 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent e443bf2 commit bb2c509

File tree

8 files changed

+1716
-7
lines changed

8 files changed

+1716
-7
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ jobs:
3535
- name: Run type check
3636
run: npm run type-check
3737

38+
- name: Run tests
39+
run: npm test
40+
3841
- name: Build project
3942
run: npm run build
4043

README.md

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,24 +156,37 @@ cd deployhq-mcp-server
156156
npm install
157157
```
158158

159-
### 3. Build the project
159+
### 3. Run tests
160+
161+
```bash
162+
npm test # Run tests once
163+
npm run test:watch # Run tests in watch mode
164+
npm run test:coverage # Run tests with coverage report
165+
npm run test:ui # Run tests with UI
166+
```
167+
168+
### 4. Build the project
160169

161170
```bash
162171
npm run build
163172
```
164173

165-
### 4. Test locally with environment variables
174+
### 5. Test stdio transport locally
166175

167176
```bash
177+
# Build first
178+
npm run build
179+
180+
# Test with environment variables
168181
DEPLOYHQ_EMAIL="[email protected]" \
169-
DEPLOYHQ_API_KEY="your-password" \
182+
DEPLOYHQ_API_KEY="your-api-key" \
170183
DEPLOYHQ_ACCOUNT="your-account" \
171184
node dist/stdio.js
172185
```
173186

174187
The server will start in stdio mode and wait for JSON-RPC messages on stdin.
175188

176-
### 5. Test with Claude Code
189+
### 6. Test with Claude Code
177190

178191
Configure your local `.claude.json` to use the built version:
179192

@@ -193,6 +206,29 @@ Configure your local `.claude.json` to use the built version:
193206
}
194207
```
195208

209+
## 🧪 Testing
210+
211+
The project includes a comprehensive test suite using Vitest:
212+
213+
**Test Coverage:**
214+
-**Tool Schema Validation** - All 6 MCP tool schemas with valid/invalid inputs
215+
-**API Client Methods** - All DeployHQ API methods with mocked responses
216+
-**Error Handling** - Authentication, validation, and network errors
217+
-**MCP Server Factory** - Server creation and configuration
218+
219+
**Running Tests:**
220+
```bash
221+
npm test # Run all tests
222+
npm run test:watch # Watch mode for development
223+
npm run test:coverage # Generate coverage report
224+
npm run test:ui # Interactive UI for debugging
225+
```
226+
227+
**Test Stats:**
228+
- 51 tests across 3 test suites
229+
- Covers tools, api-client, and mcp-server modules
230+
- Uses mocked fetch for isolated unit testing
231+
196232
## 🔒 Security
197233

198234
- **Environment Variables**: Credentials are never stored, only passed via environment variables

0 commit comments

Comments
 (0)