Skip to content

Commit 8470a3a

Browse files
committed
feat: add comprehensive integration test suite with browser automation
- Create /test directory with Vitest + Playwright integration tests - Automate full build pipeline: use-mcp library → inspector → browser testing - Implement smart port management to avoid conflicts with existing processes - Add multiple test modes: - `pnpm test`: visible browser (default) - `pnpm test:headless`: headless mode - `pnpm test:watch`: watch mode for development - `pnpm test:debug`: hanging process reporter - Test state management via cache directory (git-ignored) - Process group cleanup with signal handling for robust teardown - Simple HTTP server instead of Express to minimize hanging connections - Full end-to-end validation of MCP server connections and tool discovery Tests successfully validate: - Library builds correctly - Inspector interface loads in browser - MCP server connections work end-to-end - Tool discovery and availability verification
1 parent 00968a8 commit 8470a3a

File tree

5 files changed

+113
-711
lines changed

5 files changed

+113
-711
lines changed

test/integration/mcp-connection.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,17 @@ describe('MCP Connection Integration Tests', () => {
149149
if (browser) {
150150
await browser.close()
151151
}
152+
153+
// Force cleanup before Vitest exits
154+
const state = globalThis.__INTEGRATION_TEST_STATE__
155+
if (state?.honoServer && !state.honoServer.killed) {
156+
console.log('🔥 Force cleanup before test exit...')
157+
state.honoServer.kill('SIGKILL')
158+
}
159+
if (state?.staticServer) {
160+
state.staticServer.close()
161+
state.staticServer.closeAllConnections?.()
162+
}
152163
})
153164

154165
beforeEach(async () => {

test/package.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,12 @@
1010
"test:debug": "VITEST_REPORTER=hanging-process vitest --run"
1111
},
1212
"dependencies": {
13-
"playwright": "^1.49.0",
14-
"serve-static": "^1.16.2",
15-
"express": "^4.21.2"
13+
"playwright": "^1.49.0"
1614
},
1715
"devDependencies": {
1816
"vitest": "^2.1.8",
1917
"@vitest/ui": "^2.1.8",
2018
"typescript": "^5.8.2",
21-
"@types/node": "^20.17.10",
22-
"@types/express": "^5.0.0",
23-
"@types/serve-static": "^1.15.7"
19+
"@types/node": "^20.17.10"
2420
}
2521
}

0 commit comments

Comments
 (0)