fix: resolve CI failures in VS Code extension PR
- Fix Windows MCP test failures: use pathToFileURL() instead of bare join() paths for dynamic imports, fixing ERR_UNSUPPORTED_ESM_URL_SCHEME on Windows where D:\ paths are not valid ESM import specifiers - Remove parallel orchestration code that was WIP from another feature branch and not part of the VS Code extension scope (commands.ts, preferences.ts, types.ts changes reverted to main) - Rebase cleanly onto main, resolving mcp-server.ts merge conflict by keeping main's dynamic import approach with PR's exported interface and JSDoc documentation
This commit is contained in:
parent
d5e664c580
commit
6ed9cd5359
1 changed files with 14 additions and 7 deletions
|
|
@ -1,30 +1,37 @@
|
|||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { join } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { fileURLToPath, pathToFileURL } from 'node:url'
|
||||
|
||||
const projectRoot = join(fileURLToPath(import.meta.url), '..', '..', '..')
|
||||
|
||||
/**
|
||||
* Resolve dist path as a file:// URL for cross-platform dynamic import.
|
||||
* On Windows, bare paths like `D:\...\mcp-server.js` fail with
|
||||
* ERR_UNSUPPORTED_ESM_URL_SCHEME because Node's ESM loader requires
|
||||
* file:// URLs for absolute paths.
|
||||
*/
|
||||
function distUrl(filename: string): string {
|
||||
return pathToFileURL(join(projectRoot, 'dist', filename)).href
|
||||
}
|
||||
|
||||
test('mcp-server module imports without errors', async () => {
|
||||
// Import from the compiled dist output to avoid subpath resolution issues
|
||||
// that occur when the resolve-ts test hook rewrites .js -> .ts paths.
|
||||
const distPath = join(projectRoot, 'dist', 'mcp-server.js')
|
||||
const mod = await import(distPath)
|
||||
const mod = await import(distUrl('mcp-server.js'))
|
||||
assert.ok(mod, 'module should be importable')
|
||||
assert.strictEqual(typeof mod.startMcpServer, 'function', 'startMcpServer should be a function')
|
||||
})
|
||||
|
||||
test('startMcpServer accepts the correct argument shape', async () => {
|
||||
const distPath = join(projectRoot, 'dist', 'mcp-server.js')
|
||||
const { startMcpServer } = await import(distPath)
|
||||
const { startMcpServer } = await import(distUrl('mcp-server.js'))
|
||||
|
||||
assert.strictEqual(typeof startMcpServer, 'function')
|
||||
assert.strictEqual(startMcpServer.length, 1, 'startMcpServer should accept one argument')
|
||||
})
|
||||
|
||||
test('startMcpServer can be called with mock tools', async () => {
|
||||
const distPath = join(projectRoot, 'dist', 'mcp-server.js')
|
||||
const { startMcpServer } = await import(distPath)
|
||||
const { startMcpServer } = await import(distUrl('mcp-server.js'))
|
||||
|
||||
// Create a mock tool matching the McpToolDef interface
|
||||
const mockTool = {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue